Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a program to calculate the volume of box and cylinder object with input/output specifications as described below: Command Prompt Repeatedly asking users for valid
Write a program to calculate the volume of box and cylinder object with input/output specifications as described below: Command Prompt Repeatedly asking users for valid selection of object: 'b' for box and 'C' for cylinder 1 D:\temp\SECJ1013\Topic4>assg2 b - Box c - Cylinder Choose object (b/c): k b - Box lc - Cylinder Choose object (b/c): b 1 1 1 Repeatedly asking users for valid input of object parameters (must be an integer > 0) 1 Width: 0 I Width: 2 Height: -1 Height: 3 ! Length: 4 1 Volume of box = 24 Calculate and display the volume of the object based on the inputs given by the users: box volume => width * height + length => 2 * 3 * 4 => 24 :\temp\SECJ1013\Topic4>assg2 b - Box C - Cylinder Choose object (b/c): C 1 1 1 1 1 1 I Radius: 3 i Length: 4 Example of input and output for cylinder type object 1 1 1 Volume of cylinder = 113.04 D:\temp\SECJ1013\Topic4>. Your program must be written by following the specifications and logic as depicted in the below flowchart: Start setParam(w. h, 1) setParam(r, 1) #define PI 3.14 int width=0, height=0, length=0, radius=0 float area=0, volume=0 w = getParam"Width:") r = getParam("Radius: ") h = getParam("Height:") = getParam("Length: ") char object = chooseObject() I = getParam("Length:") FALSE Return object == 'b' setParam(radius, length) TRUE Return area = areaCircle(radius) setParam(width, height, length) getParam(pname) volume = area * length area = areaRect(width, height) Display pname Read pvalue Display cylinder volume volume = area * length TRUE pvalue #include #define PI 3.14 using namespace std; // function prototypes float areaCircle (int); float areaRect(int, int); int get Param (string); void setParam (int &, int &); void setParam (int &, int &, int &); char chooseObject(); // start main function int main() { return 0; }
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