Question: Functional Requirements Recurring rainfall calculation: Design a program called Rainfall that reads a list of numbers from the standard input (console) representing daily rainfall amounts

Functional Requirements
Recurring rainfall calculation: Design a program called Rainfall that reads a list of numbers from the standard input (console) representing daily rainfall amounts as entered by a user. Produce the average of the non-negative values in the list up to end of file. There may be negative numbers in the list.
Design and implement a program called RainfallV2 that reads a list of floating-point numbers from the standard input (console) representing daily rainfall amounts in millimeters as entered by a user. Ignore negative values, but include zero values. Produce the following statistics based on the non-negative values in the list up to end of file:
total number of (nonnegative) values read
average rainfall
cumulative rainfall
number of rainy days (defined as above the daily average)
number of dry days (defined as at most 5% of the daily average)
Input items (whole and/or floating point numbers) can be spread over one or more lines. If there is at least one input item, the program prints the resulting statistics and exits. If there is no valid numerical input item, the program prints nothing and exit.
Performance:
Time: For each additional input item, the program should produce a small, finite number of steps.
Space: For each additional input item, the program should use at most a constant amount of space.
Testability: Your program could support automatic unit testing of the core functionality, without the user entering any data or reading any data from an external file.
Implement your solution to the recurring rainfall problem as a working Java program using JUnit for testing.
Define separate classes for main (i/o), core logic, and testing.
Define a class called RainfallStats for representing the statistics given above as a single object.
In the core logic class, define a (static) method that takes a List (important: List, not just an ArrayList) and returns a RainfallStats instance.
In main, read the data into a list, initialized as an empty ArrayList, invoke the method for generating the stats, and print the resulting stats.
For testing, use Arrays.asList(x1, x2, ...) to programmatically create suitable sample test data, then use assertions (such as assertEquals) on the individual stats.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!