1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
#include <iostream>
#include <iomanip>
#include <windows.h>
using namespace std;
double rectangular (double l, double w, double h) //here I declare how the program will calculate the volume of the fish tank. (l*w*h)
{
double rect_vol;
rect_vol=l*w*h*0.00433;
return (rect_vol);
}
double fishTank (double l1, double w1, double h1) //here I declare how the fish tank will calcule tank volume from in to feet to gallons.
{
double rect_vol1;
rect_vol1=l1*w1*h1*0.00433*12;
return (rect_vol1);
}
char redo; // here I declare my variable
char choice; //choice statement allows user a menu
double l,w,h; // Important variables for conversion l = length w=width h=height
double l1,w1,h1;
double rec; // this variable is for cout of the rectangle
double rec1;
bool Quit = false;
char option;
int main()
while (!Quit){
switch (option){
case 'a':
cout<<"Enter length ";
cin>>l;
cout<<"Enter width ";
cin>>w;
cout<<"Enter height ";
cin>>h;
rec = rectangular (l,w,h);
cout << "The volume of your fish tank, in gallons, is approximately: "<< setprecision (5) << rec << endl;
break;
case 'b':
cout<<"Enter length ";
cin>>l1;
cout<<"Enter width ";
cin>>w1;
cout<<"Enter height ";
cin>>h1;
rec1 = fishTank (l1,w1,h1);
cout << "The volume of your fish tank, in gallons, is approximately: "<< setprecision (5) << rec1 << endl;
cin.get();
break;
case 'q': //user wants to quit
Quit = true;
cout << "Thanks for using my program - Robert.\n";
return 0;
break;
default:
//deal with bad input
}
}
|