Assignment: Programming Exercise
a. Write pseudocode or draw a flow chart to figure out each problem
b. Individual problem should be worked in different console application
c. Collect all .cpp files in a single folder named Assignment
d. Zip the folder and upload on canvas
1: Roman Numeral Converter
Write a program that asks the user to enter a number within the range of 1 through 10. Use a switch statement to display the Roman numeral version of that number.
Input Validation: Do not accept a number less than 1 or greater than 10.
2. The Speed of Sound
The speed of sound depends on the material the sound is passing through. Below is the approximate speed of sound (in feet per second) for air, water and steel:
air: 1,100 feet per second
water: 4,900 feet per second
steel: 16,400 feet per second
Write a program that displays a menu allowing the user to select air, water, or steel. After the user has made a selection, he or she should be asked to enter the distance a sound wave will travel in the selected medium.
The program will then display the amount of time it will take.
Menu. The menu should look exactly like this:
Select a medium:
1. Air
2. Water
3. Steel
Enter your choice:
4.18:The Speed of Sound
The speed of sound depends on the material the sound is passing through. Below is the approximate speed of sound (in feet per second) for air, water and steel:
air: 1,100 feet per second
water: 4,900 feet per second
steel: 16,400 feet per second
Write a program that displays a menu allowing the user to select air, water, or steel. After the user has made a selection, he or she should be asked to enter the distance a sound wave will travel in the selected medium. The program will then display the amount of time it will take.
Menu. The menu should look exactly like this:
Select a medium:
1. Air
2. Water
3. Steel
Enter your choice:
3: Geometry Calculator
Write a program that displays the following menu:
Geometry Calculator
1. Calculate the area of a Circle
2. Calculate the area of a Rectangle
3. Calculate the area of a Triangle
4. Quit
Enter your choice (1-4):
If the user enters 1, the program should ask for the radius of the circle and then display its area. Use the following formula:
area = p(the square of r)
Use 3.14159 for p and the radius of the circle for r.
If the user enters 2, the program should ask for the length and width of the rectangle and then display the rectangle's area.
Use the following formula:
area = length * width
If the user enters 3, the program should ask for the length of the triangle's base and its height, and then display its area.
Use the following formula:
area = base * height * .5
If the user enters 4, the program should end.
Input Validation: Display an error message if the user enters a number outside the range of 1 through 4 when selecting an item from the menu. Do not accept negative values for the circle's radius, the rectangle's length or width, or the triangle's base or height.
NOTE:
If the user enters an improper menu choice (1-4), the program prints
"The valid choices are 1 through 4. Run the program again and select one of those."
If the user enters a negative radius, the program prints "The radius can not be less than zero."
If the user enters a negative value for height or base, the program prints "Only enter positive values for base and height."
4. Software Sales
A software company sells a package that retails for $99.00. Quantity discounts are given according to the following table:
Quantity Discount
10-19 20%
20-49 30%
50-99 40%
100 or more 50%
Write a program that asks the user to input number of units sold and computes the total cost of purchase.
Input validation: Make sure number of units is greater than 0.
5. Write a program that asks for the number of calories and fat grams in a food. The program should display the percentage of calories that come from fat.
If the calories from fat are less than 30% of the total calories of the food, it should also display a message indicating food is low in fat.
One gram of fat has 9 calories, so
calories from fat = fat grams * 9
The percentage of calories from fat can be calculated as Calories from fat / total calories.
Input validation: Number of calories and fat grams can never be less than 0. Also Calories from fat cannot be greater than total number of calories. In both cases display an error message.
Format your assignment according to the following formatting requirements:
1. The answer should be typed, double spaced, using Times New Roman font (size 12), with one-inch margins on all sides.
2. The response also includes a cover page containing the title of the assignment, the student's name, the course title, and the date. The cover page is not included in the required page length.
3. Also include a reference page. The Citations and references should follow APA format. The reference page is not included in the required page length.