Question: Programming Language C++ You will ask the users to enter a character to choose which shape they want; c for circle, s for square, r

Programming Language C++

Programming Language C++ You will ask the users to enter a character

You will ask the users to enter a character to choose which shape they want; c for circle, s for square, r for rectangle, and t for triangle. Define constants for these characters. The logic of the program will be: 1) Ask the user what shape 2) based on the shape choice ask for the necessary information a) For a circle, get the radius (area = radius * radius* PI) b) For a square, get the length of a side (area = side * side) c) For a rectangle, get the height and width (area = height * width) d) For a triangle, get the height and width (area = height * width * 0.5) You should use floating point numbers for area, radius, side, length, and width. For Pl use 3.1416, rather than bothering with a more precise value. Note that PI should also be a constant. In selecting the shape, you can either use a series of if statements or a single switch statement. In either case, you should detect if the user enters an invalid code, tell they user to reenter the code, and loop back for new input. You should use a function for each of the calculations. That is, you will have four functions: circle Area, square Area, rectangle Area, and triangleArea. You should have a comment for each function explaining what it does. Each function will accept as parameters the necessary values (radius, length of a side, or width and height) and return the result of the calculation. Your main program will get all input and display all output. Make sure that your parameters and return values are all the correct types. Requirements Each function only does the calculations, all needed values are passed in and the resulting area is returned. Constants are defined and used for the characters selecting the shape and for Pl

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!