In: Computer Science
The manager of Fish Haven wants a program that displays the number of gallons of water a rectangular aquarium holds, given the aquarium’s length, width, and height measurements in inches. (Hint: There are 231 cubic inches in a gallon.)a.Using the chart shown earlier in Figure 4-12 as a guide, enter the input, processing, and output items, as well as the algorithm, in the first column. b.Desk-check the algorithm twice. For the first desk-check, use 20.5, 10.5, and 12.5 as the length, width, and height measurements. For the second desk-check, use 30, 9, and 14. c.Enter the C++ instructions in the second column of the chart, and then desk-check the program using the same data used to desk-check the algorithm.d.If necessary, create a new project named Introductory12 Project, and save it in the Cpp8\Chap04 folder. Enter your C++ instructions into a source file named Introductory12.cpp. Also enter appropriate comments and any additional instructions required by the compiler. Test the program using the same data used to desk-check the program.
C++ CODE: ( Introductory12.cpp )
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
// variable to store the length, width, height
double length;
double width;
double height;
//variable to store the volume, gallons
double volume;
double gallons;
// getting the length from the user
cout<<"Enter the length: ";
cin>>length;
// getting the width from the user
cout<<"Enter the width: ";
cin>>width;
// getting the height from the user
cout<<"Enter the height: ";
cin>>height;
// calculating the volume
volume= length * width * height;
// calculating the gallons
gallons = volume/231;
//displaying the gallons
cout<<"\nNumber of gallons of water in aquarium:
"<<setprecision(2)<<fixed<<gallons;
return 0;
}
ALGORITHM:
1. start
2. input length, width, height
3. calculate volume = length * width * height
4. calculate gallons = volume /231
5. print "Number of gallons in aquarium =", gallons
5. end
SCREENSHOT FOR OUTPUT: