Simple Membuat Sistem Kasir C++

Nama: Zamzam Saputra NIM: 2021310116
 avatar
zamisyh
c_cpp
2 years ago
3.7 kB
2
Indexable
Never
/*
    Author: Zamzam Saputra
*/

#include <iostream>
#include <cctype>
#include <string.h>
#include <cstring>
#include <stdlib.h>
#include <stdio.h>

using namespace std;

class App {
    public: 
        int total;
        int subtotal;
        int hargaLevel;
        int diskon;
        string namaMenu;
        int hargaMenu;
        float getDiskon;

        string menu;

        void setLevel(int);
        void setPaket(char);
        void setBeli(int);
        void setDiskon(int);
        void setTotal(int);

        void setHeaderMenu(){
            cout << "Menu : " << endl;
            cout << "1. Level 1" << endl;
            cout << "2. Level 2" << endl;
            cout << "3. Level 3" << endl;
            cout << "4. Level 4" << endl;
            cout << "5. Level 5" << endl;

        };
};

void App::setLevel(int level){
    switch (level)
    {
    case 1:
        this->hargaLevel = 1000;
        break;
    case 2:
        this->hargaLevel = 2000;
        break;
    case 3:
        this->hargaLevel = 3000;
        break;
    case 4: 
        this->hargaLevel = 4000;
        break;
    case 5: 
        this->hargaLevel = 5000;
    default:
        break;
    }
};

void App::setPaket(char paket){
    if (paket == 'A' || paket == 'a')
    {
        this->namaMenu = "Ayam Geprek + Keju Mozarella";
        this->hargaMenu = 28000;
    }else if (paket == 'B' || paket == 'b')
    {
        this->namaMenu = "Ayam Geprek + Sambal Matah";
        this->hargaMenu = 25000;
    }else if(paket == 'C' || paket == 'c' ){
        this->namaMenu = "Ayam Geprek + Sambal Terasi";
        this->hargaMenu = 22000;
    }
    
};

void App::setBeli(int jumlahBeli){
   App::subtotal = (this->hargaMenu + this->hargaLevel) * jumlahBeli;
};

void App::setDiskon(int jumlahBeli){
  if (jumlahBeli >= 3 && jumlahBeli < 6)
  {
     this->diskon = 2;
     this->getDiskon = 0.02;
  }else if(jumlahBeli >= 6){
    this->diskon = 10;
    this->getDiskon = 0.1;
  }else{
    this->diskon = 0;
  }
  
};



int main(int argc, char const *argv[])
{   
    char paket, goTop, goBottom;
    int level, jumlahBeli, totalBayar, dibayar, kembalian;
    float jumlahDiskon;
    char title[] = "Ayam Geprek Membahana Zamzam";
    //set object
    App myObj;
    int total;

   goTop : 
   system("clear");

    //  strupr(title);
    cout << "AYAM GEPREK MEMBAHANA ZAMZAM" << endl;
    cout << "===========================" << endl;
    cout << "Pilih paket [A/B/C] : "; cin >> paket;
    cout << "" << endl;
    myObj.setHeaderMenu();
    cout << "" << endl;
    cout << "Pilih Level [1/2/3/4/5] : "; cin >> level;
    cout << "" << endl;
    cout << "===========================" << endl;

    // Result
    myObj.setPaket(paket);
    cout << "Menu : " << myObj.namaMenu << endl;
    cout << "Harga : " << myObj.hargaMenu << endl;

    myObj.setLevel(level);
    cout << "Tambah Level : " << myObj.hargaLevel << endl;

    cout << "Jumlah Beli : "; cin >> jumlahBeli;
    cout << "Subtotal : "; myObj.setBeli(jumlahBeli); cout << myObj.subtotal << endl;
    cout << "Diskon : "; myObj.setDiskon(jumlahBeli); cout << myObj.diskon << "%" << endl;
    
    //hitung diskon
    totalBayar = myObj.subtotal - ( myObj.diskon * myObj.subtotal / 10);


    cout << "Total Bayar : " << totalBayar << endl;
   
    cout << "Uang Bayar : "; cin >> dibayar;
    
    //hitung kembalian
    kembalian = dibayar - totalBayar;
    cout << "Uang Kembali : " << kembalian << endl;
    
    cout << "" << endl;
    
    cout << "Input lagi ? [Y/T] : "; cin >> goBottom;

    if (goBottom == 'Y' || goBottom == 'y')
    {
        goto goTop;
    }else if (goBottom == 'T' || goBottom == 't'){
        exit(0);
    }



    return 0;


}