Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
5.9 kB
2
Indexable
Never
#include <iostream>

using namespace std;

struct order {
    char kode;
    string menu;
    int jumlah, harga, diskon, subtotal;
};

int i = 0;
char confirm = 'y';
string bonus;
int total_bayar, total, diskon;

int main()
{
    order ord[6];

    cout << "             Daftar Harga\t\t\n";
    cout << "    Ayam Goreng Gerobak Fried Chicken\t\t\n";
    cout << "-----------------------------------------\n";
    cout << "=========================================\n";
    cout << "| Kode Menu |   Nama Menu   |   Harga   |\n";
    cout << "=========================================\n";
    cout << "|     D     |      Dada     | Rp. 5000  |\n";
    cout << "|     P     |      Paha     | Rp. 4000  |\n";
    cout << "|     S     |      Sayap    | Rp. 3000  |\n";
    cout << "|     T     |      Teh      | Rp. 3000  |\n";
    cout << "|     J     |      Jeruk    | Rp. 4000  |\n";
    cout << "|     C     |      Sirup    | Rp. 5000  |\n";
    cout << "=========================================\n";

    while(confirm != 'n'){
        cout << "Silahkan masukkan pilihan menu anda (kode menu (contoh : d)): ";
        cin >> ord[i].kode;
            switch(ord[i].kode){
            case 'd' :
                ord[i].menu = "Dada";
                ord[i].harga = 5000;
                cout << "Order #" << i+1 << endl;
                cout << ord[i].menu << endl;
                cout << "Jumlah Order : ";
                cin >> ord[i].jumlah;
                ord[i].subtotal = ord[i].harga*ord[i].jumlah;
                total_bayar += ord[i].subtotal;
                i++;
            break;
            case 'p' :
                ord[i].menu = "Paha";
                ord[i].harga = 4000;
                cout << "Order #" << i+1 << endl;
                cout << ord[i].menu << endl;
                cout << "Jumlah Order : ";
                cin >> ord[i].jumlah;
                ord[i].subtotal = ord[i].harga*ord[i].jumlah;
                total_bayar += ord[i].subtotal;
                i++;
            break;
            case 's' :
                ord[i].menu = "Sayap";
                ord[i].harga = 3000;
                cout << "Order #" << i+1 << endl;
                cout << ord[i].menu << endl;
                cout << "Jumlah Order : ";
                cin >> ord[i].jumlah;
                ord[i].subtotal = ord[i].harga*ord[i].jumlah;
                total_bayar += ord[i].subtotal;
                i++;
            break;
            case 't' :
                ord[i].menu = "Teh";
                ord[i].harga = 3000;
                cout << "Order #" << i+1 << endl;
                cout << ord[i].menu << endl;
                cout << "Jumlah Order : ";
                cin >> ord[i].jumlah;
                ord[i].subtotal = ord[i].harga*ord[i].jumlah;
                total_bayar += ord[i].subtotal;
                i++;
            break;
            case 'j' :
                ord[i].menu = "Jeruk";
                ord[i].harga = 4000;
                cout << "Order #" << i+1 << endl;
                cout << ord[i].menu << endl;
                cout << "Jumlah Order : ";
                cin >> ord[i].jumlah;
                ord[i].subtotal = ord[i].harga*ord[i].jumlah;
                total_bayar += ord[i].subtotal;
                i++;
            break;
            case 'c' :
                ord[i].menu = "Sirup";
                ord[i].harga = 5000;
                cout << "Order #" << i+1 << endl;
                cout << ord[i].menu << endl;
                cout << "Jumlah Order : ";
                cin >> ord[i].jumlah;
                ord[i].subtotal = ord[i].harga*ord[i].jumlah;
                total_bayar += ord[i].subtotal;
                i++;
            break;
            default :
                cout << "Menu tidak ditemukan silahkan order lagi";
            break;
            }
        cout << "Apakah mau order lagi (y/n)?";
        cin >> confirm;
    }

    cout << endl;
    cout << "                 Invoice Order\n";
    cout << "-------------- GEROBAK FRIED CHICKEN -------------\n";
    cout << "==================================================\n";
    cout << "No. \tItem\tJumlah\tHarga\t\tSubtotal \n";
    cout << "==================================================\n";
    for(int a = 0; a < i; a++){
        cout << a+1 << "\t" << ord[a].menu << "\t" << ord[a].jumlah<< "\t" << ord[a].harga << "\t\t" << "Rp. " << ord[a].subtotal << "\n";

    };


    if(total_bayar < 50000){
        total_bayar = 0;
        bonus = "-";
    }else if(total_bayar <=  100000 ){
        total_bayar = total*5/100;
        bonus = "Cangkir";
    }else if(total_bayar <= 200000){
        total_bayar = total*10/100;
        bonus = "Kaos";
    }else if(total_bayar <= 500000){
        diskon = total_bayar*15/100;
        bonus = "Payung";
    }else if(total_bayar > 500000){
        diskon = total_bayar*20/100;
        bonus = "Tas Pinggang";
    };

    cout << "                                                                            \n";
    cout << "                          Total         " << "Rp. " << total_bayar << "\n";
    cout << "                          Diskon        " << "Rp. " << diskon << "\n";
    cout << "                                        ----------\n";
    cout << "                                        " << "Rp. " << total_bayar - diskon << "\n";
    total = total_bayar - diskon;
    cout << "                          PPN \t\t" << "Rp. " << total*10/100 << "\n";
    cout << "                                        ----------\n";
    cout << "                          Grnd Total    " << "Rp. " << total_bayar - diskon + total*10/100 << "\n";
    cout << "                          Bonus \t" << bonus << "\n";


    return 0;
}