0% found this document useful (0 votes)
11 views5 pages

Switch Kunohay

The document is a C++ program that implements a simple console-based restaurant ordering system. It provides a main menu for food items and a beverage menu, allowing users to select items and quantities, and calculates the total cost. The program continues to prompt the user for choices until they decide to exit.

Uploaded by

Klint Ayco
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views5 pages

Switch Kunohay

The document is a C++ program that implements a simple console-based restaurant ordering system. It provides a main menu for food items and a beverage menu, allowing users to select items and quantities, and calculates the total cost. The program continues to prompt the user for choices until they decide to exit.

Uploaded by

Klint Ayco
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

using namespace std;

void clearConsole() {
system("cls");
}

void showMenu() {
cout << "=====================" << endl;
cout << " MAIN MENU " << endl;
cout << "=====================" << endl;
cout << "1. Burger - $5.99" << endl;
cout << "2. Pizza - $8.99" << endl;
cout << "3. Salad - $4.49" << endl;
cout << "4. Fries - $2.99" << endl;
cout << "5. Exit" << endl;
cout << "=====================" << endl;
}

void showDrinkMenu() {
cout << "=====================" << endl;
cout << " BEVERAGE MENU " << endl;
cout << "=====================" << endl;
cout << "1. Coke/Sprite/Royal/MTN Dew - $1.99" << endl;
cout << "2. Calamansi/Nestea 1L - $2.49" << endl;
cout << "3. Tubig - $0.99" << endl;
cout << "4. Coffee - $1.99" << endl;
cout << "5. No Drink" << endl;
cout << "=====================" << endl;
}
double calculateTotal(double price, int quantity) {
return price * quantity;
}

void handleChoice(int& mainChoice, int& mainQuantity, int& drinkChoice, int&


drinkQuantity) {
double mainPrice = 0.0, drinkPrice = 0.0;

// Main dish selection


switch (mainChoice) {
case 1:
mainPrice = 5.99;
cout << "You picked Burger ($5.99)." << endl;
break;
case 2:
mainPrice = 8.99;
cout << "You picked Pizza ($8.99)." << endl;
break;
case 3:
mainPrice = 4.49;
cout << "You picked Salad ($4.49)." << endl;
break;
case 4:
mainPrice = 2.99;
cout << "You picked Fries ($2.99)." << endl;
break;
case 5:
cout << "Exiting..." << endl;
return;
default:
cout << "Invalid choice. Please try again." << endl;
return;
}

// Get quantity for the main dish


cout << "Enter the quantity of main dish: ";
cin >> mainQuantity;

// Drink selection
showDrinkMenu();
cout << "Enter your beverage of choice (1-5): ";
cin >> drinkChoice;

switch (drinkChoice) {
case 1:
drinkPrice = 1.99;
cout << "You selected Coke/Sprite/Royal/MTN Dew ($1.99)." << endl;
break;
case 2:
drinkPrice = 2.49;
cout << "You selected Calamansi/Neste 1L ($2.49)." << endl;
break;
case 3:
drinkPrice = 0.99;
cout << "You selected Tubig ($0.99)." << endl;
break;
case 4:
drinkPrice = 1.99;
cout << "Your selected Coffee ($1.99)." << endl;
break;
case 5:
cout << "No drink selected." << endl;
drinkQuantity = 0;
break;
default:
cout << "Invalid drink choice. No drink selected." << endl;
drinkQuantity = 0;
break;
}

// Get quantity for the drink (if selected)


if (drinkChoice >= 1 && drinkChoice <= 3) {
cout << "Enter the quantity of drinks: ";
cin >> drinkQuantity;
}

// Calculate totals
double totalMain = calculateTotal(mainPrice, mainQuantity);
double totalDrink = calculateTotal(drinkPrice, drinkQuantity);
double totalCost = totalMain + totalDrink;

cout << fixed << setprecision(2); // Ensure the price shows 2 decimal places
cout << "Total cost for " << mainQuantity << " main dish(es): $" << totalMain
<< endl;
cout << "Total cost for " << drinkQuantity << " drink(s): $" << totalDrink <<
endl;
cout << "Overall Total: $" << totalCost << endl;
}

int main() {
int mainChoice, mainQuantity, drinkChoice, drinkQuantity;

do {
clearConsole();
// Show main menu and get choice
showMenu();
cout << "Enter your choice for main dish (1-5): ";
cin >> mainChoice;

// Handle both main dish and drink selection


if (mainChoice != 5) {
handleChoice(mainChoice, mainQuantity, drinkChoice, drinkQuantity);
}

if (mainChoice != 5) {
cout << "Press Enter to continue..." << endl;
cin.ignore();
cin.get(); // Wait for user input before clearing the screen
}

} while (mainChoice != 5);

return 0;
}

You might also like