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;
[Link]();
[Link](); // Wait for user input before clearing the screen
}
} while (mainChoice != 5);
return 0;
}