Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in this c + + program I need to complete the body and design of the function CylVol, which is designed to compute and return

in this c++ program I need to complete the body and design of the function CylVol, which is designed to compute and return the volume of a cylinder, based on the radius and the height given as input parameters
#include
#include
#include
using namespace std;
/************************ Global Data Declarations ****************************/
//None in this program
/**************************** Function Prototypes *****************************/
//Computes the volume of a cylinder
float CylVol(float radius, //IN: Radius of cylinder
float height); //IN: Height of cylinder
/*******************************************************************************
* Function Name: main
* Author: Timothy D. Stedman
* Date: 12 May 2024
* Function Description:
* The function will first ask the user for the radius and height of two
* cylinders. It will then calculate the volume of both cylinders. Finally,
* it will display two volumes formatted to 3 decimal places.
*
* Pseudocode:
* Level 0
*-------
* Ask user for Cylinder 1 radius and height
* Ask user for Cylinder 2 radius and height
* Calculate volume of Cylinder 1
* Calculate volume of Cylinder 2
* Set formatting for 3 decimal places
* Display volume of Cylinder 1
* Display volume of Cylinder 2
* Level 1
*-------
* Ask user for Cylinder 1 radius and height
* Output "Cylinder 1:", EOL
* Output " radius --->"
* Input rad1
* Output " height --->"
* Input h1
* Ask user for Cylinder 2 radius and height
* Output EOL
* Output "Cylinder 2:", EOL
* Output " radius --->"
* Input rad2
* Output " height --->"
* Input h2
* Calculate volume of Cylinder 1
* vol1= CylVol(rad1, h1)
* Calculate volume of Cylinder 2
* vol2= CylVol(rad2, h2)
* Display volume of Cylinder 1
* Output EOL, EOL
* Output "Volume of Cylinder 1=", vol1," cubic units.", EOL
* Display volume of Cylinder 2
* Output "Volume of Cylinder 2=", vol2," cubic units.", EOL
*******************************************************************************/
int main()
{
//Local constants
//None in this function
//Local variables
float rad1; //Radius of Cylinder 1
float h1; //Height of Cylinder 1
float rad2; //Radius of Cylinder 2
float h2; //Height of Cylinder 2
float vol1; //Volume of Cylinder 1
float vol2; //Volume of Cylinder 2
/******************* Begin main Function Executables **********************/
//Ask user for Cylinder 1 radius and height
cout << "Cylinder 1:"<< endl;
cout <<" radius --->";
cin >> rad1;
cout <<" height --->";
cin >> h1;
//Ask user for Cylinder 2 radius and height
cout << endl;
cout << "Cylinder 2:"<< endl;
cout <<" radius --->";
cin >> rad2;
cout <<" height --->";
cin >> h2;
//Calculate volume of Cylinder 1
vol1= CylVol(rad1, h1);
//Calculate volume of Cylinder 2
vol2= CylVol(rad2, h2);
//Set formatting for 3 decimal places
cout << fixed << showpoint << setprecision(3);
//Display volume of Cylinder 1
cout <<"
";
cout << "Volume of Cylinder 1="<< vol1<<" cubic units." << endl;
//Display volume of Cylinder 2
cout << "Volume of Cylinder 2="<< vol2<<" cubic units." << endl;
//Indicate to OS successful termination of program
return 0;
}//End main
/*******************************************************************************
* Function Name: CylVol
* Author: Your Name
* Date: XX May 2024
* Function Description:
* The function compute the volume of a cylinder, based on the radius and the
* height given as input parameters. The function will return the calculated
* value through the function name.
*
* Pseudocode:
* Level 0
*-------
*
*******************************************************************************/
float CylVol(float radius, //IN: Radius of cylinder
float height)//IN: Height of cylinder
{
//Local constants
//Local variables
/****************** Begin CylVol Function Executables *********************/
}//End CylVol

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

Beyond Big Data Using Social MDM To Drive Deep Customer Insight

Authors: Martin Oberhofer, Eberhard Hechler

1st Edition

0133509796, 9780133509793

More Books

Students also viewed these Databases questions

Question

write about your research methods.

Answered: 1 week ago