0

About a code.

Hey, I have been trying for a few days to figure out what how to get my code to compile. can someone figure out the issue? #include <iostream> #include <iomanip> using namespace std; int main() { int choose; double length, width, area; double radius; // Constants for numbers const double PI = 3.14; // Constants for menu choices const double 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; // Set the output formatting cout << fixed << showpoint << setprecision(2); // B) Enter input from user. if (choose SQUAREROOM > 0) { cout << "Please enter the width of the room."; cin >> width; area = width*width; cout << "The area of the squareroom is" << area << endl; } if (choose RECTANGULARROOM > 0) { cout << "Enter the length and width of the room."; cin >> length >> width; area = length*width; cout << "The area of the rectangular room is" << area << endl; } if (choose ROUNDROOM > 0) { cout << " Enter the radius of the room."; cin >> radius; area = PI*(radius*radius); cout << "The area of the round room is" << area << endl; } if (choose QUIT ) { cout << "Thank you for using Haverly's Room Calculator..."; } return 0; }

19th Oct 2018, 7:01 AM
K.D
K.D - avatar
1 Resposta
+ 2
The comparison in your if-statements should look like if (choose == SQUAREROOM) {...} and so on. You also might want to use int for those constants (except for PI, of course), even if it is technically not neccessary.
19th Oct 2018, 7:19 AM
Shadow
Shadow - avatar