Switch Kunohay
Switch Kunohay
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;
}
// 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;
}
// 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;
if (mainChoice != 5) {
cout << "Press Enter to continue..." << endl;
cin.ignore();
cin.get(); // Wait for user input before clearing the screen
}
return 0;
}