Question: *****WITH COMMENTS PLEASE****** Write a program that reads in lines from the input. For every line, it reads in the numbers in the line and

 *****WITH COMMENTS PLEASE****** Write a program that reads in lines from

*****WITH COMMENTS PLEASE******

Write a program that reads in lines from the input. For every line, it reads in the numbers in the line and then prints their sum, average, min, and max Note that this problem is an advanced version on 006 Three Numbers problem. Input The format of an input line is k input inputz inputs... inputk where k is an integer and input,, input, etc are all real numbers. Note there are k real numbers on the line. The first integer in the line, i.e. k, is the number of real numbers that will be supplied in that line Output Each line of output consists of the sum, the average, the min, and the max of the k real numbers on the line These are printed using %10.2f format and are separated by a single space Sample Input 5 1.0 2.0 3.0 4.0 5.0 11 51.94 96.63 27.05 48.42 95.97 81.35 59.3 28.01 44.29 35.9 68.56 1 55.22 Sample Output 15.00 637.42 55.22 3.00 57.95 55.22 1.00 27.05 55.22 5.00 96.63 55.22 HINT 1. To find max and min see section 4.5.4 (page 149) of text book. 2. Instead of setting the largest to in.nextDouble() at the beginning - set double largest Double.MIN VALUE; Similarly, set double smallest Double. MAX_ VALUE; at the beginning. Rest will be similar. 3. First read the integer k. Then, L00P k times each time reading a number and adding to the sum, fixing the max and the min. After reading all the k items, you can compute the average (sum/k) and print using the correct format. 4. To print, use System.out . printf("%10.2f", sum) ; etc

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!