Question: C++ help! Write a program that can compute the area of several geometric objects: circle, square, triangle. Use overloaded functions for each geometric shape. The
C++ help!
Write a program that can compute the area of several geometric objects: circle, square, triangle. Use overloaded functions for each geometric shape. The function calls should look something like:
a = area(diam); //circle version
a = area(side); //square version
a = area(side1, angle, side2); //triangle version
Length of diameter should be an int , and length of side should be a double. and the angle for the triangle area should be a double. Each function should return doubles. The formula for the area of a triangle (SAS) is 0.5*a*b*sin(). **include the cmath library. Also, the version of sin() in cmath takes radians as input so youll need to convert from degrees to radians (use a function for this). Also include a void function that prints the result of the area calculation. The function should take two arguments: shape type (as a character) and area. Make sure the program goes back to the main menu after performing the calculation until the user selects Exit (use a while loop around your menu structure to accomplish this). Assume the user enters valid input (e.g. dont worry about selecting 5 which isnt on the menu). Here's what I have:
#include#include using namespace std; double area(int diam); double area(double side); double area(int side1, double angle, int side2); double d2r(double degrees); void print(char type, double area); int main() { return 0; } void print(char type, double area) { return; }
**Sample Output** (user input in italics)
Which shape would you like to calculate the area of?
1 - Circle
2 - Square
3 - Triangle
4 Exit > 1
Enter the diameter: 4
The area of that circle is 12.56
Which shape would you like to calculate the area of?
1 - Circle
2 - Square
3 - Triangle
4 - Exit > 2
Enter the side of a square: 5
The area of square is 25
Which shape would you like to calculate the area of?
1 - Circle
2 - Square
3 - Triangle
4 - Exit > 3
Enter the 1st side followed by the angle (deg) followed by the 2nd side: 4 70 5
The area of that triangle is 9.39481
Which shape would you like to calculate the area of?
1 Circle
2 Square
3 Triangle
4 Exit > 4
Exiting
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
