Question: How would this look in C++. It must contain a loop, can someone explain the process behind the loop. The sample must match the input

How would this look in C++. It must contain a loop, can someone explain the process behind the loop. The sample must match the input exactly.

The user will enter a series of numbers, one at a time, that represent the ages of patients at the onset of the disease. The program will compute and print these results: The number of patients in the study. The number of patients in each of three age categories: o Children (0-17) o Young adults (18-49) o Seniors (50+) The average age of the patients. The age of the oldest patient. The age of the youngest patient. Input The program will prompt the user for each patient's age. It must work correctly for an arbitrary number of patients. The prompt must include a sequence number, beginning with #1 for the first entry. See the example on the next page. The user will enter only the ages, not the sequence numbers. The program must compute and display the correct sequence numbers. The user will enter the number 1 to serve as a sentinel at the end of the input. Output The program must compute and display the results itemized above. Use the same output the format that is illustrated by the sample on the next page.

Sample Run The sample below shows how the screen must look when your program runs. You must strictly follow this format, wording, spacing, and alignment, including the number of decimal places on the numbers. The characters in red are typed by the user. The other characters are output by the program. Sample Run Parvy-19 Patient Ages --------------------- Patient #1: 38 Patient #2: 70 Patient #3: 63 Patient #4: 8 Patient #5: 17 Patient #6: 45 Patient #7: 89 Patient #8: 15 Patient #9: 22 Patient #10: 12 Patient #11: 4 Patient #12: -1 Number of patients -- 11 Children ------------ 5 Young adults -------- 3 Seniors ------------- 3 Average age --------- 34.8 Oldest -------------- 89 Youngest ------------ 4

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!