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
|
#include <iostream>
#include <iomanip>
using namespace std;
const char SENTINEL = 'Q';//found this suggestion online to quit a program
int main ()
{
char V, A, G, inputChar;
float length, width, depth, totalV, totalA, totalG;
cout<<"Enter character V for Volume, character A for Surface Area,\n";
cout<<"character G or Girth plus Depth or Q to quit\n"<<endl;
cin>>inputChar;// pick letter
while (inputChar!=SENTINEL)// if not Q then check the if-ele statments
{
switch (inputChar)
case 'V':
{
cout<<"Enter Length, Width, and Depth for Volume\n";
cin>>length, width, depth;
totalV=length*width*depth;//math for volume
cout<<"The Volume = "<<totalV<<endl;
break;
}
case 'A':
{
cout<<"Enter Length, Width, and Depth for Surface Area\n";
cin>>length, width, depth;
totalA=2*length*width+2*width*depth+2*length*depth;//math for area
cout<<"The Surface Area = "<<totalA<<endl;
break;
}
case 'G':
{
cout<<"Enter Length, Width, and Depth for Girth\n";
cin>>length, width, depth;
totalG=2*(length+width)+depth;//math for girth
cout<<"The Girth = "<<totalG<<endl;
break;
}
}
system ("pause");
return 0;
}
|