Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Upgrading Oracle Databases Oracle Database New Features

Authors: Charles Kim, Gary Gordhamer, Sean Scott

1st Edition

B0BL12WFP6, 979-8359657501

More Books

Students also viewed these Databases questions

Question

1.what is the significance of Taxonomy ?

Answered: 1 week ago

Question

What are the advantages and disadvantages of leasing ?

Answered: 1 week ago

Question

Name is needed for identifying organisms ?

Answered: 1 week ago

Question

What does Processing of an OLAP Cube accomplish?

Answered: 1 week ago