Answered step by step
Verified Expert Solution
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 value;
double value;
double area ;
case r: accept a lower case
case R:
cout "RECTANGLE Solve for area
;
cout "Length: ;
cin value;
value getPositive value;
cout "Width: ;
cin value;
value
value;
area
value value;
cout "Area area endl;
break;
case s:
case S:
cout "SQUARE Solve for area
;
cout "Side: ;
cin value;
value
value;
area
;
cout "Area area endl;
break;
case t:
case T:
cout "TRIANGLE Solve for area
;
cout "Base: ;
cin value;
value
value;
cout "Height: ;
cin value;
value getPositive value;
area
value value;
cout "Area area endl;
break;
case c:
case C:
cout "CIRCLE Solve for area
;
cout "Radius: ;
cin value;
value
value;
area
value;
cout "Area area endl;
break;
case n: case N: case y: case Y: nNyY 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 ;
functions implementation
double
dblVal
while
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;
double
double r
const double PI ;
return
r r;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started