Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Shapes . 1 . cpp #include #include #include #include #include #include using namespace std; void calculateSquare ( double side ) { double area = side
Shapescpp
#include
#include
#include
#include
#include
#include
using namespace std;
void calculateSquaredouble side
double area side side;
double perimeter side;
cout "SQUARE side side area area perimeter perimeter endl;
void calculateRectangledouble length, double width
double area length width;
double perimeter length width;
cout "RECTANGLE length length width width area area perimeter perimeter endl;
void calculateCircledouble radius
double area MPI radius radius;
double perimeter MPI radius;
cout "CIRCLE radius radius area area perimeter perimeter endl;
void calculateCubedouble side
double surfaceArea side side;
double volume side side side;
cout "CUBE side side surface area surfaceArea volume volume endl;
void calculateBoxdouble length, double width, double height
double surfaceArea length width length height width height;
double volume length width height;
cout "BOX length length width width height height surface area surfaceArea volume volume endl;
void calculateCylinderdouble radius, double height
double surfaceArea MPI radius radius height;
double volume MPI radius radius height;
cout "CYLINDER radius radius height height surface area surfaceArea volume volume endl;
void calculatePrismdouble side, double height
double area sqrt side side;
double surfaceArea area side height;
double volume area height;
cout "PRISM side side height height surface area surfaceArea volume volume endl;
void handleInvalidObjectconst string& objectName
cout objectName invalid object" endl;
int main
ifstream inputFileShapesinput.txt;
string line;
while getlineinputFile line
if lineempty
continue;
istringstream issline;
string shape;
iss shape;
if shape "SQUARE"
double side ;
iss side;
if side
calculateSquareside;
else
handleInvalidObjectSQUARE;
else if shape "RECTANGLE"
double length width ;
iss length width;
if length && width
calculateRectanglelength width;
else
handleInvalidObjectRECTANGLE;
else if shape "CIRCLE"
double radius ;
iss radius;
if radius
calculateCircleradius;
else
handleInvalidObjectCIRCLE;
else if shape "CUBE"
double side ;
iss side;
if side
calculateCubeside;
else
handleInvalidObjectCUBE;
else if shape "BOX"
double length width height ;
iss length width height;
if length && width && height
calculateBoxlength width, height;
else
handleInvalidObjectBOX;
else if shape "CYLINDER"
double radius height ;
iss radius height;
if radius && height
calculateCylinderradius height;
else
handleInvalidObjectCYLINDER;
else if shape "PRISM"
double side prismHeight ;
iss side prismHeight;
if side && prismHeight
calculatePrismside prismHeight;
else
handleInvalidObjectPRISM;
else
handleInvalidObjectshape;
inputFile.close;
return ;
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