I need help getting the height of the trapezoid and rectangl
I need help getting the height of the trapezoid and rectangle for this in PYTHON program!!!!!
I get the user\'s input for the rectangles or trapezoids, beginning value and ending value. I got the width of the rect/trap
I just don\'t know how to get the height of rect/trap.
I dont need the full program. I just need to see how it works in coding wise.
These are the functions that must be in the Python program!!!!!!!!!
Solution
include <iostream>
#include <iomanip>
using namespace std;
int main()
{
const double PI = 3.14159;
double radius=0.0;
double area=0.0;
double length=0.0;
double width=0.0;
double base=0.0;
double base1=0.0;
double base2=0.0;
double height=0.0;
int choice=0;
cout << \"Geometry Calculator\ \";
cout << \"\ \";
cout << \"1. Calculate the area of a Circle\ \";
cout << \"2. Calculate the area of a Rectangle\ \";
cout << \"3. Calculate the area of a Triangle\ \";
cout << \"4. Calculate the area of a Trapezoid\ \";
cout << \"5. Calculate the area of a Sphere\ \";
cout << \"6. Exit\ \ \";
cout << \"Enter your choice (1-6): \";
cin >> choice;
if (choice>=1 && choice<=6)
{
switch (choice)
{
case 1: //Area of Circle
cout << \"\ \";
cout << \"Enter the circle\'s radius: \";
cin >> radius;
if (radius>0)
{
area = (PI * radius * radius);
//cout << fixed << setprecision(4);
cout << \"The area is \" << area;
break;
case 2: //Area of Rectangle
cout << \"\ \";
cout << \"Enter the rectangle\'s length: \";
cin >> length;
cout << \"Enter the rectangle\'s width: \";
cin >> width;
if (length>0 && width>0)
{
area = length * width;
cout << \"The area is \" << area;
break;
case 3: //Area of Triangle
cout << \"Enter the length of the base: \";
cin >> base;
cout << \"Enter the triangle\'s height: \";
cin >> height;
if (base>0 && height>0)
{
area = (base * height)/2;
cout << \"The area is \" << area;
break;
case 4: //Area of a Trapezoid
cout << \"Enter the Trapezoid\'s height\";
cin >> height;
cout << \"Enter the Trapezoid\'s base 1\";
cin >> base1;
cout << \"Enter the Trapezoid\'d base 2\";
cin >> base2;
if (base1>0 && base2>0 && height>0)
{
area = (height * (base1 + base2))/2;
cout << \"The area is \" << area;
break;
case 5: //Area of a Sphere
cout << \"Enter the Sphere\'s radius\";
cin >> radius;
if (radius>0);
{
area = (4)*(PI * radius * radius)
cout << \"The area is \" << area;
break;
case 6: //Exit
cout << \"Program Ending.\";
break;
}
}
else
{
cout << \"The valid choices are 1 through 6. Run the\ program again and select one of those.\";
}
return 0;
}



