#include <iostream>
#include <iomanip>
#include <cstdlib>
usingnamespace std;
constint SENTINEL = 'Q'; // Type this to close our loop
int main()
{
char opLetter = ' ';
float volume, length, width, depth, area, girth;
while(opLetter != SENTINEL)
{
cout << "For Area type A, or a\n"
<< "For Volume type V, or v\n"
<< "For Girth type G, or g\n"
<< "To exit this program type Q, or q"<< endl;
cin >> opLetter;
//This allows you to use upper case or lower case to terminate program
if (opLetter == 'Q' || opLetter == 'q')
{
cout << "Program terminated" << endl;
break;
}
//Asking user to input Length, Width and Depth
cout << "Please enter your length, width and depth " << endl;
cin >> length >> width >> depth;
switch (opLetter)
{
case'a':
case'A':
area = 2 * (length*width) + 2 * (width*depth) + 2 *(length*depth);
cout << "The area is " << area << endl;
break;
case'v':
case'V':
volume = length * width * depth;
cout << "The volume is " << volume <<endl;
break;
case'g':
case'G':
girth = 2 * (width + length) + depth;
cout << "The Girth is " << girth <<endl;
break;
}
system("pause");
return 0;
}
}
After getting a little help earlier on my sentinel mess up, I finally got that to work. However, after a user completes his or her calculation, the program breaks, I want to give the user the option to continue the loop by adding an option to continue by enter y or completely stopping by pressing n. I can't get it to work no matter what I try, so again can someone shove me in the right direction? THANKS!