Question: Write a well-documented (commented) program in Java called Average, that reads in lines from standard input with each line containing a name and three integers

Write a well-documented (commented) program in Java called Average, that reads in lines from standard input with each line containing a name and three integers and then uses printf() to print a table with a column of the names, the integers, and the average of the three integers accurate to two decimal places. The user will specify the number of names as a command-line argument and then type in at least that number of names (along with three integers for each name). He would signal the end of input by pressing Control D (or Control Z and then Enter on Windows).

It should have only one class (Average). Also the program should continuously allow user input until CTRL+Z or CTRL+D is pressed to end the input.

  • A sample run would be as follows.

> java Average 4

Joe 3 5 2

Tim 4 1 5

Jane 6 3 2

Jack 8 3 5

Jill 5 4 9

Mike 6 7 3

OUTPUT:

Joe 3 5 2 3.33

Tim 4 1 5 3.33

Jane 6 3 2 3.67

Jack 8 3 5 5.33

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!