My menu isn't very intuitive.

closed account (iyv9E3v7)
My menu isnt very intuitive. How can I make it a case-switch menu instead? Also, I would like for the program to eventually display results when the user choose DONE. It keeps exiting.

Basically, I have an assignment where I need to provide this information:

Write an application for a Carpet Installation company that provides the quote for Carpet Installation for different
shapes
1. Square
2. Rectangle
3. Circle
4. Triangle.
5. DONE
For each shape, you should display the message and read the information enough to calculate the area of selected
shape.
The program should allow users to continue to add more shapes to the quote until users select to Done
After calculating the area of all rooms, calculate the total of the area of all selected shapes then calculate the
carpet cost with the carpet unit price is $2.59/square feet
The labor cost will be calculated: $32.5/per 100 square feet
The tax will be: 8.25% on both the carpet cost and the labor cost




Here is the code:

#include <iostream> // Header files

using namespace std;

int main()

{ // main function

double length, width, side, radius, base, height, rectangle, square, circle, triangle, total, carpetCost, laborCost, subTotal, taxCost, totalCost, flag = 0; // required variables

{
int option; // user's entered option will be saved in this variable
do //do-while loop starts here.that display menu again and again until user select to exit program
{
//Displaying Options for the menu
cout << "1) Rectangle " << endl;
cout << "2) Square " << endl;
cout << "3) Circle" << endl;
cout << "4) Triangle " << endl;
cout << "5) DONE. " << endl;
//Prompting user to enter an option according to menu
cout << "Please select an option : ";
cin >> option; // taking option value as input and saving in variable "option"

if (option == 1) // Checking if user selected option 1
{
//Rectangle
cout << "Enter Width of the Rectangle : "; cin >> width; // getting values 1. width of rectangle
cout << "Enter Length of the Rectangle : "; cin >> length; // 2. length of rectangle

}
else if (option == 2) // Checking if user selected option 2
{
//Square
cout << "Enter Side of the Square : "; cin >> side; // 3. side of sqaure

}
else if (option == 3) // Checking if user selected option 3
{
//Circle
cout << "Enter Radius of the Circle : "; cin >> radius; // 4. radius of circle

}
else if (option == 4) // Checking if user selected option 3
{
//Triangle
cout << "Enter Base of the Triangle : "; cin >> base; // 5. base of triange
cout << "Enter Height of the Triangle : "; cin >> height; // 6. height of triangle

}
else if (option == 5) // Checking if user selected option 5 DONE.
{
cout << "Terminating Program" << endl;
}
else //if user has entered invalid choice (other than 1,2,3 or 4)
{
//Displaying error message
cout << "Invalid Option entered" << endl;
}
} while (option != 5); //condition of do-while loop

rectangle = width*length; square = side*side; circle = (22 / 7)*radius*radius; triangle = (base*height) / 2; // calculating areas of rectangle, sqaure, circle and triangle
}

{
cout << "CARPET INSTALLATION QUOTE" << endl; // display results

cout << "Shape : RECTANGLE" << endl << "Length : " << length << endl << "Width : " << width << endl << "Area : " << rectangle << endl;

cout << "Shape : SQUARE" << endl << "Side : " << side << endl << "Area : " << square << endl;

cout << "Shape : CIRCLE" << endl << "Radius : " << radius << endl << "Area : " << circle << endl;

cout << "Shape : TRIANGLE" << endl << "Base : " << base << endl << "Height : " << height << endl << "Area : " << triangle << endl;

total = rectangle + square + circle + triangle; carpetCost = total*2.59; laborCost = (total*32.5) / 100; subTotal = laborCost + carpetCost; taxCost = (subTotal*8.25) / 100; totalCost = taxCost + subTotal; // claculating costs and taxes

cout << "Total area : " << total << "(Square Feet)" << endl << "Carpet Cost : " << carpetCost << endl << "Labor Cost : " << laborCost << endl << "Sub Total : " << subTotal << endl;

cout << "Tax : " << taxCost << endl << "Total of charge : " << totalCost << endl; // displaying
}


system("pause");

return 0;

}// end of main
Please, use code tags for readability.

[.code.]
Code here...
[./code.]

Remove the dots (.). I put them there so the text wouldn't actually be formatted as code.

Example of code-tags:

1
2
3
4
5
6
7
8
9
10
#include <iostream>

int main()
{
    std::cout << "Hello World!\n";

    std::cin.get();

    return 0;
}
Last edited on
Topic archived. No new replies allowed.