Question: Finish the program below that uses a nested loop to compute the sum, product, and average of rows of numbers given in input. The program

Finish the program below that uses a nested loop to compute the sum, product, and average of rows of numbers given in input. The program will quit when the user inputs something that is not a number.

 Finish the program below that uses a nested loop to compute

import java util. public class Lab5c public static void main (String args Scan the input Scanner scan [Your code here] Process each line separately If the next token is a double, assume there is an input line while (scan .hasNextDouble Get a line from the input String line [Your code here] Create a scanner for the line of input you have read Scanner linescan [Your code here] Write a while loop that will sum all of the double values on the line (hint: create double variables called "sum", product and "count". Set sum and count to 0, and product to 1 Then read as many double values as you can using the while loop When you read a number add it to sum, multiply product by it, and add 1 to count [Your code here] Compute the average by dividing sum by count [Your code here] Print out the sum, product, and average on one line [Your code here]

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!