Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Recommended Textbook for

Modern Database Management

Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi

12th edition

133544613, 978-0133544619

More Books

Students also viewed these Databases questions