Question: /// Using Java You shall write a program that reads in an arbitrary number of data points from standard input, formatted as follows, where each

/// Using Java You shall write a program that reads in an arbitrary number of data points from standard input, formatted as follows, where each value is separated by whitespace: Date (String) Time (String) Value (int) For example, input data might look like this (the output from weather -t temp all | head -10): 2013-08-20 01:00:01 58 2013-08-20 01:05:02 58 2013-08-20 01:10:01 57 2013-08-20 01:15:02 57 2013-08-20 01:20:01 57 2013-08-20 01:25:02 57 2013-08-20 01:30:01 57 2013-08-20 01:35:01 57 2013-08-20 01:40:02 57 2013-08-20 01:45:01 57 Your program shall determine the number of values, the maximum value, the minimum value, and the average value (to double precision), along with the date and time at which the extreme values occurred, and print those data, formatted as in the examples below. Further specifications and tips Do not repeatedly create a Scanner object for reading from standard input. Create it once and reuse it. You can simulate the end of standard input on the terminal by pressing Ctrl-D. This also works in Eclipse's console on Mac or GNU/Linux. On Windows (including in Eclipse on Windows), the equivalent is Ctrl-Z. If you get stuck in a loop, Ctrl-C will usually kill the program. Print the average value to two digits after the decimal point. Your program need not account for unexpected/malformed input data. Consider using the hasNext method of the Scanner class to control whether your program repeats the process of reading input. You may find the predefined constants Integer.MIN_VALUE and Integer.MAX_VALUE useful. If an extremum is not unique, opt for the date and time where the extremum is first encountered. Include appropriate comments in your code, describing your approach. Pseudocode for reading in the input might look something like this: while Scanner hasNext() returns true: Read the date with Scanner's next() method Read the time with Scanner's next() method Read the value with Scanner's nextInt() method Example I/O Possible sessions follow, describing expected I/O. Commands are also given, assuming the class containing the main method is namedAssignment04. The values related to the output from the weather program are correct as of this writing, but correct output will change over time. Command: echo 'DummyDate1 DummyTime1 50 DummyDate2 DummyTime2 10 DummyDate3 DummyTime3 75' | java Assignment04 Output: Count: 3 Minimum: 10 @ DummyDate2 DummyTime2 Maximum: 75 @ DummyDate3 DummyTime3 Average: 45.00 Command: weather -t temp all | head -10 | java Assignment04 Output: Count: 10 Minimum: 57 @ 2013-08-20 01:10:01 Maximum: 58 @ 2013-08-20 01:00:01 Average: 57.20 Command: weather -t temp all | java Assignment04 Output: Count: 319947 Minimum: 28 @ 2013-12-09 05:40:01 Maximum: 98 @ 2015-08-15 18:40:04 Average: 57.73 Command: weather -t pressure all | java Assignment04 Output: Count: 319947 Minimum: 995 @ 2014-02-28 04:35:02 Maximum: 1031 @ 2014-11-25 07:05:03 Average: 1016.59

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!