this is C++ 3. (Lastname_Lab2_p3.cpp) Write a program that displays the followin
ID: 3665598 • Letter: T
Question
this is C++
3. (Lastname_Lab2_p3.cpp) Write a program that displays the following prompts: Enter the length of the swimming pool (ft) Enter the width of the swimming pool (ft) Enter the average depth of the swimming pool (ft): After each prompt is displayed, your program should use acin to accept swimming pool is entered, your program should calculate and display the volume of the pool (volume-length * width * average depth) Convert the volume from cubit foot to gallon using the equation volume in gallons = volume in cubic foot * 7.48; Assume the price of resident water is $2.56 per 1000 gallons, calculate and display the water cost of the swimming pool.Explanation / Answer
// header file
#include<iostream>
using namespace std;
ion
// define main funct
int main()
{
// declare local variables
double l, w, h, volg, volf, price;
// asking user to enter length of swimming pool
cout<<"Enter the length of the swimming pool (ft)."<<endl;
cin>>l;
// asking user to enter width of swimming pool
cout<<"Enter the width of the swimming pool."<<endl;
cin>>w;
// asking user to enter depth of swimming pool
cout<<"Enter the average depth of the swimming."<<endl;
cin>>h;
// calculate volume of pool
volf=l*w*h;
// calculate volume in gallons
volg=volf*7.48;
// display vlume of pool in gallons
cout<<"The volume of the pool is "<<volg<<" gallons."<<endl;
// calculate price of pool
price= volg*(3.11/1000);
// display price of pool
cout<<"The price to create the pool is "<<price<<" dollars."<<endl;
return 0;// return successfully to function main
}
Sample output
Enter the length of the swimming pool (ft).10
Enter the width of the swimming pool. 15
Enter the average depth of the swimming. 5
The volume of the pool is 5610 gallons.
The price to create the pool is 17.4471 dollars.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.