Question: Question 1: Write a C++ program that will calculate the area of 6 different plane shapes. All variables are of type double. The main program

Question 1: Write a C++ program that will calculate the area of 6 different plane shapes. All variables are of type double. The main program (30 points- 5 points for each function call related code) will call/test the following 6 different functions in the following order: (8 points) Triangle area : The function reads the values of the base and height variables from the user, calculates the area, and then prints the value of the area to screen. Use the following formula to calculate the area: Triangle Area = 0.5 x base x height (8 points) Square area: The function reads the value of lengthOfSide from user, calculates the area, and then returns the value of the area to the main program using the return statement. The main program will print the value of the area. Use the following formula to calculate the area: Square Area = lengthOfSide 2 (8 points) Rectangle_area: The function reads the values of the variables width and height from the user, calculates the area and then sends that value to the main program via the parameters list. The main program will print the value of the area. Use the following formula to calculate the area: RectangleArea = width x height (8 points) Parallelogram area: The main program sends the values of the variables base and verticalHeight to the function. The function calculates the area and prints the value of the area. Use the following formula to calculate the area: Parallelogram_area= base x verticalHeight (8 points) Trapezoid_area: The main program sends the values of the variables upperWidth , lowerWidth and verticalHeight to the function. The function calculates the area and sends it back to main program using the return statement. The main program prints the value of the area. Use the following formula to calculate the area: Trapezoid area = 0.5 (upperWidth + lowerWidth) x verticalHeight (8 points) Circle area: The main program sends the value of the radius to the function. The function calculates the area and sends it back to main program through the parameter list. The main program will print the value of the area. Use the following formula to calculate the area: Circle area= 3.14 x radius 2
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
