Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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++
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 PlStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started