Question: USE A WHILE LOOP AND THE INDEFINITE LOOP PATTERN Research on who use different kinds of computers. They are curious if there is any difference

USE A WHILE LOOP AND THE INDEFINITE LOOP PATTERN

Research on who use different kinds of computers. They are curious if there is any difference in average test scores between , for instance, Mac users and Windows users. Write a program to help with this, that behaves as follows.

  • The user repeatedly enters a computer type, picking Mac, Windows or Other by entering "m", "w", or "o", along with a test score from 0 to 100. The user enters "x" to indicate they are done inputting data.

  • The program will calculate the average test score for each computer type separately.

    • Note that this means you need 3 separate counters and 3 separate accumulators, one for each computer type. Each time a computer type and score is entered, you need to update the appropriate accumulator and counter. A switch would be very useful here!

  • When all input is complete, calculate and display the average test score for each computer type, with one decimal place.

  • If there are no students for a particular computer type, instead of outputting an average test score, only output "No Windows users", "No Mac users" or "No Other users".

  • Your program must work for upper or lowercase. In other words, all of these are valid inputs for computer type: "M", "m", "W", "w", "O", "o", "X", "x". This is easiest to do with a String variable and a switch statement with cases "stacked" on top of each other, or convert the string to upper or lower case before starting the switch.

  • For this problem you can assume no invalid data.

Sample output (Test case 1)

Enter (M)ac, (W)indows or (O)ther, or X to quit: w

Enter test score: 85

Enter (M)ac, (W)indows or (O)ther, or X to quit: m

Enter test score: 93

Enter (M)ac, (W)indows or (O)ther, or X to quit: W

Enter test score: 80

Enter (M)ac, (W)indows or (O)ther, or X to quit: W

Enter test score: 85

Enter (M)ac, (W)indows or (O)ther, or X to quit: M

Enter test score: 100

Enter (M)ac, (W)indows or (O)ther, or X to quit: o

Enter test score: 75

Enter (M)ac, (W)indows or (O)ther, or X to quit: x

Average Mac user score: 96.5

Average Window user score: 83.3

Average Other user score: 75.0

Coded by yourname

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!