Kedai Lemonade Jack

Dibuat khas untuk demonstration dalam C++ Beginner Volume 1
 avatar
SirSyafi
c_cpp
a month ago
1.6 kB
110
Indexable
Never
/*
Title : Kedai Lemonade Jack
Author : Syafi Hakim

Description : Program ini dibuat khas untuk demonstration dalam C++ Beginner Volume 1

Play around and have fun with it!

*/

#include <iostream>

using namespace std;

int main()
{
    int lemCups = 0;
    int tembCups = 0;

    string repeat = "y";
    while(repeat == "y") {
        int cups;
        cout << "Berapa cawan anda beli: ";
        cin >> cups;

        string juiceType;
        cout << "Jus yang dibeli (L/T): ";
        cin >> juiceType;

        while(juiceType != "L" && juiceType != "T") {
            cout << "(Warning) Masukkan L/T sahaja: ";
            cin >> juiceType;
        }

        if (juiceType == "L") {
            double amtLemo;
            amtLemo = cups * 3;
            cout << "Lemonade : RM " << amtLemo << endl;
            lemCups = lemCups + cups;
        }

        if (juiceType == "T") {
            double amtTemb;
            amtTemb = cups * 4;
            cout << "Tembikai : RM " << amtTemb << endl;
            tembCups = tembCups + cups;
        }

        cout << endl;
        cout << "Next Customer? (y/n): ";
        cin >> repeat;
        cout << endl;
    }

    int totalCupsSold;
    totalCupsSold = tembCups + lemCups;

    int totalSale;
    totalSale = tembCups*4 + lemCups*3;

    cout << "We sold " << lemCups<< " Lemonades" << endl;
    cout << "We sold " << tembCups<< " Watermelon" << endl;
    cout << "Total of " << totalCupsSold << "Cups Sold" << endl;
    cout << "Our total sale is RM " <<  totalSale << endl;


    return 0;
}

Leave a Comment