Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Explain in detail how the Mughal Empire was established in India

Answered: 1 week ago

Question

Problem: Evaluate the integral: I - -[ze dx

Answered: 1 week ago

Question

Problem: Evaluate the integral: I = 1- 1 dx 9

Answered: 1 week ago