Problem Statement: The perimeter, approximate surface area, the approximate volume of an in ground pool are given by the following formula:
Perimeter=2(length+width)
Volume=length*width*average depth
Underground surface area=2(length+width)average depth +length*width
Perimeter=2(length+width)
Volume=length*width*average depth
Underground surface area=2(length+width)average depth +length*width
Using these formula as basis, write a program that accepts the length, width and average depth measurements, and then calculates the perimeter, volume and underground surface area of the pool. In writing your program, make the following two calculations immediately after the input data has been entered: length*width and length+width. The results of these two calculations should then be used, as appropriate,l n the assignments statements for determining the perimeter, volume, and underground surface area without recalculation them for each equation. Verify the results of your program by doing doing a hand calculation using the following test data: length equalts 25 feet, width equals 15 feet, and average depth equals 5.5 feet. When you have verified that your program is working, use it to complete the following table.
CODE:
CODE:
/**
Laboratory Exercise #2
CS10-B5
@author Red Berroy
*/
#include<iostream.h>
int main ()
{
float length,width,depth,perimeter,volume,surface_area;
//Variable names
cout<<"Enter length: ";
cin>>length;
//Enter length
cout<<"Enter width: ";
cin>>width;
//Enter width
cout<<"Enter depth: ";
cin>>depth;
//Enter depth;
perimeter=2*(length+width);
volume=(length*width*depth);
surface_area=perimeter*depth+length*width;
//Formulas
cout<<" "<<endl;
//Line break
cout<<"Perimeter is: "<<perimeter<<endl;
cout<<"Volume is: "<<volume<<endl;
cout<<"Underground Surface Area is: "<<surface_area<<endl;
//Display results
return 0;
}
0 comments:
Post a Comment