Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- // Softdrinks
- int pepsi = 20;
- int coke = 25;
- // Bread
- int sandwich = 25;
- int bun = 20;
- // Snacks
- int oishi = 15;
- int pewee = 18;
- // User choices
- char category;
- string choice;
- // Money calculations variables
- int totalAmount;
- int payment;
- int change;
- cout << "Our menu:" << endl;
- cout << "A. Softdrinks (Pepsi = 20 ; Coke = 25)" << endl;
- cout << "B. Bread (Sandwich = 25 ; Bun = 20)" << endl;
- cout << "C. Snacks (Oishi = 15 ; Peewee = 18)" << endl;
- cout << "Choose category: ";
- cin >> category;
- cout << "Choose item: ";
- switch(category) {
- case 'A':
- case 'a':
- cin >> choice;
- if (choice == "Pepsi" || choice == "pepsi") {
- totalAmount = pepsi;
- } else if (choice == "Coke" || choice == "coke") {
- totalAmount = pepsi;
- }
- break;
- case 'B':
- case 'b':
- cin >> choice;
- if (choice == "Sandwich" || choice == "sandwich") {
- totalAmount = sandwich;
- } else if (choice == "Bun" || choice == "bun") {
- totalAmount = bun;
- }
- break;
- case 'C':
- case 'c':
- cin >> choice;
- if (choice == "Oishi" || choice == "oishi") {
- totalAmount = oishi;
- } else if (choice == "Peewee" || choice == "pewee") {
- totalAmount = pewee;
- }
- }
- cout << "Total amout is: " << totalAmount << endl;
- cout << "Your payment: ";
- cin >> payment;
- if (payment < totalAmount) {
- cout << "Payment insufficient" << endl;
- } else {
- change = payment - totalAmount;
- cout << "Here's your change: " << change << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement