0

About a code.

Hi, I am getting my code to compile. But when i try entering the Number 2 is telling me "Program ended with the code : 02. How can I fix that so that I can enter 2 and not have to enter the #1 everytime. #include <iostream> #include <iomanip> using namespace std; int main () { int choose; double length, width, area; double radius; const double PI = 3.14; const int SQUAREROOM = 1, RECTANGULARROOM = 2, ROUNDROOM = 3, QUIT = 4; // A) Show Haverly's Room Calculator. cout << "Haverly's Room Calculator: \n"; cout << "******************************\n"; cout << "1. Square Room\n"; cout << "2. Rectangular Room\n"; cout << "3. Round Room\n"; cout << "4. Quit\n"; cout << endl; cout << "Please enter a menu item(1-4)\n"; cin >> choose; if (choose == SQUAREROOM >=(1-3)) { cout << "Enter the width of the room.\n"; cin >> width; area = width*width; cout << "The area of the squareroom is \n" << area << endl; } if (choose == RECTANGULARROOM >=(1-3)) { cout << "Enter the length and width of the room.\n"; cin >> length >> width; area = length*width; cout << "The area of the rectangular room is \n" << area << endl; } if (choose == ROUNDROOM >=(1-3)) { cout << "Enter the radius of the room.\n"; cin >> radius; area = PI*radius*radius; cout << "The area of the roundroom is \n" << area << endl; } if (QUIT == 4) { cout << "Thank you for using Haverly's Calculator. \n"; } return 0; }

25th Oct 2018, 2:18 PM
K.D
K.D - avatar
2 Answers
+ 3
put your code in a loop
25th Oct 2018, 2:23 PM
Taste
Taste - avatar
+ 2
you can use switch case and do while loop
25th Oct 2018, 4:17 PM
Shruti
Shruti - avatar