The speed of sound varies depending on the medium through which it travels. In general, sound travels fastest in rigid media, such as steel, slower in liquid media, such as water, and slowest of all in gases, such as air. The following table shows the approximate speed of sound, measured in feet per second, in air, water, and steel.
Medium | Speed (feet per sec.) |
Air | 1,100 |
Water | 4,900 |
Steel | 16,400 |
Write a program that displays a menu allowing the user to select air water, or steel. After the user has made a selection, the number of feet a sound wave will travel in the selected medium should be entered. The program will then display the amount of time it will take. (Round the answer to four decimal places.)
Input Validation: Decide how the program should handle an illegal input for the menu choice or a negative value for the distance.
Write a program that computes and displays the charges for a patient's hospital stay. First, the program should ask if the patient was admitted as an inpatient or an outpatient. If the patient was an inpatient, the following data should be entered:
If the patient was an outpatient, the following data should be entered:
Use a single, separate function to validate that no input is less than zero. If it is, it should be reentered before being returned.
Once the required data has been input and validated, the program should use two overloaded functions to calculate the total charges. One of the functions should accept arguments for the inpatient data, while the other function accepts arguments for outpatient data. Both functions should return the total charges.
Create one function that sends the output report to the screen and one other function that sends the exact, same report to a file. Call both functions so that the same output goes to the file and the screen when the program is executed.