Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#include using namespace std; / / functions prototypes double getPositive ( dblVal ) ; getRectangleNSquareArea ( double l , double w ) ; getTriangleArea (

#include
using namespace std;
//functions prototypes
double getPositive(
dblVal );
getRectangleNSquareArea( double l, double w );
getTriangleArea( double b, double h );
double getCircleArea(
r ) ;
int main(){
char input;
{
cout <<"------------------------------
";
cout << "Welcome to a geometry calculator!
";
cout << "Insert 'R' for Rectangle.
";
cout << "Insert 'S' for Square.
";
cout << "Insert 'T' for Triangle.
";
cout << "Insert 'C' for Circle.
";
cout <<"
Insert 'Y' to continue.
";
cout << "Insert 'N' to finish the program.
";
cout <<"------------------------------
";
cout << "Please select your choice
";
cout << "Input: ";
cin >> input;
double value1=0;
double value2=0;
double area =0;
(
){
case 'r':// accept a lower case
case 'R':
cout << "RECTANGLE - Solve for area
";
cout << "Length: ";
cin >> value1;
value1= getPositive( value1);
cout << "Width: ";
cin >> value2;
value2=
( value2);
area =
( value1, value2);
cout << "Area ="<< area << endl;
break;
case 's':
case 'S':
cout << "SQUARE - Solve for area
";
cout << "Side: ";
cin >> value1;
value1=
( value1);
area =
(
,
);
cout << "Area ="<< area << endl;
break;
case 't':
case 'T':
cout << "TRIANGLE - Solve for area
";
cout << "Base: ";
cin >> value1;
value1=
( value1);
cout << "Height: ";
cin >> value2;
value2= getPositive( value2);
area =
(value1, value2);
cout << "Area ="<< area << endl;
break;
case 'c':
case 'C':
cout << "CIRCLE - Solve for area
";
cout << "Radius: ";
cin >> value1;
value1=
( value1);
area =
( value1);
cout << "Area ="<< area << endl;
break;
case 'n': case 'N': case 'y': case 'Y': //n,N,y,Y are valid input
break;
default:
cout << "INVALID INPUT - Try again!
";
}
}
((input !='N')
(input !='n'))
cout <<"
*****************************************
";
cout <<"* KEEP CALM AND CODE ON AND BE SAFE! *";
cout <<"
*****************************************
";
return 0;
}
//functions implementation
double
(
dblVal ){
while(
0){
cout << "Try again!
A positive number please: ";
cin >> dblVal;
}
dblVal;
}
double
( double l, double w ){
return l *
;
}
double
( double b, double h ){
return (b * h)/2;
}
double
( double r ){
const double PI =3.14;
return
*(r * r);

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

MySQL/PHP Database Applications

Authors: Jay Greenspan, Brad Bulger

1st Edition

978-0764535376

More Books

Students also viewed these Databases questions