Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. Write a program that asks the user to input the radius and height of a cylind

ID: 3533306 • Letter: 1

Question

1. Write a program that asks the user to input the radius and height of a cylinder and the unit weight of the material (in pounds per square feet). The program computes the surface area of the cylinder and the total weight of the cylinder. The program uses two functions:

One function to read the data from the keyboard, the other function to calculate the surface area and the weight of the cylinder. The weight of the cylinder is printed from the function main.

N.B. surface area of cylinder = 2 * radius * height *22/7

Total weight = surface area * unit weight

Explanation / Answer

#include<iostream>

using namespace std;

void readData(float &radius,float &height,float &weight)

{

cout << "Input the radius of the cylinder : ";

cin >> radius;

  

cout << "Input the height of the cylinder : ";

cin >> height;

  

cout << "Input the unit weight of cylinder(in pounds per square feet) : ";

cin >> weight;

}

void displayCalculation(float radius,float height,float weight)

{

float area,weight_;

  

area = (2*radius*height*22)/7.0;

weight_ = area*weight;

  

  

cout << "Surface area is : " << area << endl;

cout << "Total weight is : " << weight_ << endl;

}

int main()

{

float height,radius,weight;

readData(radius,height,weight);

displayCalculation(radius,height,weight);

return 0;

}