The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Jul 2017 |
| Last Sign in: | 304 Weeks Ago, 3 Days Ago |
| Questions Answered: | 15833 |
| Tutorials Posted: | 15827 |
MBA,PHD, Juris Doctor
Strayer,Devery,Harvard University
Mar-1995 - Mar-2002
Manager Planning
WalMart
Mar-2001 - Feb-2009
language is c++
-HW4-2.pdf has output of the program.
homework 4.docx has question.
due on 03/29 at 6 pm. it asked us to use function.
help plz!!!!
Homework #4
 due March 29 at 6 PM
This homework assignment gives you the opportunity to practice menus, functions, conditional statements (what is meant by conditional statement is a statement such as if, if/else if, switch, and not necessarily a conditional ternary operator) and input validation.
HW4 (Graded out of 100) Exercise 23, page 225, Geometry Calculator 1.
Exercise 23- 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 π r 2
Use 3.14159 for π 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.
Â
· You are required to write the following functions and call them in the main() function
·getChoice: displays the menu of choices, reads and returns the user’s choice
·calculateCircleArea: prompts the user to input the radius, performs input validation (radius cannot be negative). If input is valid, calculates the area and returns the result as a double. If input is invalid, print an error message and return -1. Do not ask the user to reenter an input. For consistency across the submissions, use this value for Pi: const double PI = 3.14159;
·calculateRectArea: prompts the user to input the width and height, performs input validation (width and height cannot be negative). If input is valid, calculates the area and returns the result as a double. If input is invalid, print an error message and return -1. Do not ask the user to reenter an input.
·calculateTriangleArea: prompts the user to input the base and height, performs input validation (base and height cannot be negative). If input is valid, calculates the area and returns the result as a double. If input is invalid, print an error message and return -1. Do not ask the user to reenter an input.
· Your main() function implements the following pseudocode call getChoice to get the user’s choice perform input validation on the user’s choice (choice must correspond to a menu item) and call the appropriate function to calculate the area, or exit. Display the area if result returned is valid (not equal to -1). If the user’s choice is not on the menu, print an error message.
2. Example Output Here are some examples of output if your program is correct. Output of HW4
Â
Â
Â
Â
Â
Â
Â
Â
Â
Â
Â
Â
Â
Â
Â
Â
                                   Â
Â
Â
Â
Â
----------- Â ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly