Question: C++ requirements Your program will read in the menu number as an unsigned int value . The menu item must be processed using a switch

C++ requirements

Your program will read in the menu number as an unsigned int value .

The menu item must be processed using a switch statement.

The distance and all calculations need to be done using double values.

Failure to follow the C++ requirements could reduce the points received from passing the tests.

General overview

You will be calculating the number of seconds it will take for sound to travel though a medium. The values you will use are as follows:

Medium Speed (feet per second)
Air 1,100
Water 4,900
Steel 16,400

Your program will display a menu of three items:

Select the medium that sound is traveling through: 1 Air 2 Water 3 Steel 

After displaying the menu your program will read in the menu item as an unsigned int value .

Use a switch statement to process the menu value you have just read in. If the value is invalid (0, or greater than 3) display the following error message:

The menu value is invalid. Please run the program again. 

If the menu value is valid, read in the distance (in feet) that sound will travel in the medium selected. This will look as follows:

Enter distance (in feet) 

The distance value must be read into a variable of type double.

If the distance is less than or equal to zero output the message:

The distance must be greater than zero 

If the distance is greater than zero, calculate the speed and output the following (this is for air):

Air: 1000.000 ft Traveled for 0.909 seconds 

Note that the output values have three digits of precision.

Here are two sample runs (with input):

Run 1:

3 567544.986 

Here is the output:

Select the medium that sound is traveling through: 1 Air 2 Water 3 Steel Enter distance (in feet) Steel: 567544.986 ft Traveled for 34.606 seconds 

Run 2:

12 

Here is the output:

Select the medium that sound is traveling through: 1 Air 2 Water 3 Steel The menu value is invalid. Please run the program again.

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!