Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Coded in C 1. Write a program using a switch statement to calculate means for a set of random numbers. Seed the random number generator

Coded in C
image text in transcribed
1. Write a program using a switch statement to calculate means for a set of random numbers. Seed the random number generator with time and generate four random integers between the values of 5 and 25. Print the numbers. Create a menu and prompt the user to enter the type of mean to be calculated. The user should enter A for arithmetic mean, H for harmonic mean, or G for geometric mean. The mean type will be the switch variable. The program should allow for entry of upper or lower case characters and should include an error message (default) for entry of an invalid character. Within the chosen case, calculate the mean using the appropriate formula below: arithmetic mean +x. + x + x geometric_mean- *x* x2 * x, *x, Print the mean with two decimal digits within the case or after exiting the switch. When the program is working, modify it using a while or do...while loop so that the program will continue prompting the user to see if another mean is to be calculated. After the chosen mean is printed the user will be asked if he wants to calculate another mean. He might enter Y (or 1) to continue or N (or 0) to quit. Use the same random numbers for each mean calculated

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

More Books

Students also viewed these Databases questions

Question

2. Define communication.

Answered: 1 week ago