Question: Help needed. It must be in C++ For this assignment, you are to compute the areas of four different geometric shapes: circle, square, rectangle, and
Help needed. It must be in C++


For this assignment, you are to compute the areas of four different geometric shapes: circle, square, rectangle, and triangle. 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* Pl) 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 triangle Area. 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. Each function must have at least one comment. Your program and functions must be properly indented
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
