Program penggabungan switch case, looping dan function C++ Menggunakan KodeBlocks

program menghitung pembayaran service handphone mullyana cell
ini adalah satu tugas pemrograman yang saya buat untuk gabungan dari looping, switch case, fungsi, semoga ini menjadi nilai + buat yang membaca.



source code :
#include <conio.h>
#include <iostream>
using namespace std;

int transaksi(int jumlah[5],int b){
    int hasil=0;

    for(int a=0;a<b;a++){
        hasil=jumlah[a]+hasil;
    }
    return hasil;
}

int main (){
    int jumlah[5],harga[20],count[5],jenis[5],a,b,c, pilihan,bayar;
    char lanjut, pilihan_merek;
    cout<<"-----------------------------------------------------"<<endl;
    cout<<"-------------------MULYANA CELL----------------------"<<endl;
    cout<<"-----------------------------------------------------"<<endl;
cout<<"\t MEREK HANDPHONE "<<endl;
cout<<endl;
cout<<"\t 1. SAMSUNG "<<endl;
cout<<"\t 2. XIAOMI "<<endl;
cout<<"\t 3. HUAWEI"<<endl;
cout<<"\t 4. OPPO "<<endl;
cout<<"\t 5. ADVAN "<<endl;
cout<<"\t 6. POLYTRON "<<endl;
cout<<"\t 7. EVERCOSS "<<endl;
cout<<"\t 8. SMARFREN "<<endl;
cout<<"\t 9. IPHONE "<<endl;
cout<<"\t 10. ZYREX"<<endl;
cout<<"\t 11. HIMAX "<<endl;
cout<<"\t 12. ACER "<<endl;
cout<<"\t 13. ASUS"<<endl;
cout<<"\t 14. COOLPAD "<<endl;
cout<<"\t 15. LENOVO "<<endl;
cout<<"\t 16. LG "<<endl;
cout<<"\t 17. MEIZU "<<endl;
cout<<"\t 18. NOKIA "<<endl;
cout<<"\t 19. NEXIAN "<<endl;
cout<<"\t 20. SHARP "<<endl;
cout<<"\t 21. SONY "<<endl;
cout<<"\t 22. VIVO "<<endl;
cout<<"\t 23. WIKO"<<endl;
cout<<"\t 24. ZTE"<<endl;
cout<<"\t 25. ONEPLUS "<<endl;
cout<<"\t 26. ALCATEL"<<endl;
cout<<"\t 27. MITO "<<endl;
cout<<"\t 28. ALDO"<<endl;
cout<<endl;
int samsung=1;
int xiaomi=2;
int huawei=3;
int oppo=4;
int advan=5;
int polytron=6;
int evercoss=7;
int smarfren=8;
int iphone=9;
int zyrex=10;
int himax=11;
int acer=12;
int asus=13;
int coolpad=14;
int lenovo=15;
int lg=16;
int meizu=17;
int nokia=18;
int nexian=19;
int sharp=20;
int sony=21;
int vivo=22;
int wiko=23;
int zte=24;
int oneplus=25;
int alcatel=26;
int mito=27;
int aldo=28;
for (int a=0; a<1; a++)
    {
    cout<<"\t Masukan merek handphone anda yang rusak anda [1-28] :";
    cin>>pilihan;
    if (pilihan==1){
        cout<<"\t\t SAMSUNG"<<endl;
        }
        else if(pilihan==2){
            cout<<"\t XIAOMI"<<endl;
        }
        else if(pilihan==3){
            cout<<"\t HUAWEI"<<endl;
        }
        else if(pilihan==4){
            cout<<"\t OPPO"<<endl;
        }
        else if(pilihan==5){
            cout<<"\t ADVAN"<<endl;
        }
        else if(pilihan==6){
            cout<<"\t POLYTRON"<<endl;
        }
        else if(pilihan==7){
            cout<<"\t EVERCOSS"<<endl;
        }
        else if(pilihan==8){
            cout<<"\t SMARFREN"<<endl;
        }else if(pilihan==9){
            cout<<"\t IPHONE"<<endl;
        }
        else if(pilihan==10){
            cout<<"\t ZYREX"<<endl;
        }
        else if(pilihan==11){
            cout<<"\t HIMAX"<<endl;
        }
        else if(pilihan==12){
            cout<<"\t ACER"<<endl;
        }
        else if(pilihan==13){
            cout<<"\t ASUS"<<endl;
        }
        else if(pilihan==14){
            cout<<"\t COOLPAD"<<endl;
        }
        else if(pilihan==15){
            cout<<"\t LENOVO"<<endl;
        }
        else if(pilihan==16){
            cout<<"\t LG"<<endl;
        }
        else if(pilihan==17){
            cout<<"\t MEIZU"<<endl;
        }
        else if(pilihan==18){
            cout<<"\t NOKIA"<<endl;
        }
        else if(pilihan==19){
            cout<<"\t NEXIAN"<<endl;
        }
        else if(pilihan==20){
            cout<<"\t SHARP"<<endl;
        }
        else if(pilihan==21){
            cout<<"\t SONY"<<endl;
        }
        else if(pilihan==22){
            cout<<"\t VIVO"<<endl;
        }
        else if(pilihan==23){
            cout<<"\t WIKO"<<endl;
        }
        else if(pilihan==24){
            cout<<"\t ZTE "<<endl;
        }
        else if(pilihan==25){
            cout<<"\t ONEPLUS"<<endl;
        }
        else if(pilihan==26){
            cout<<"\t ALCATEL"<<endl;
        }
        else if(pilihan==27){
            cout<<"\t MITO"<<endl;
        }
        else if(pilihan==28){
            cout<<"\t ALDO"<<endl;
        }
         else{
        cout<<"\t\t Merek hp anda tidak ada "<<endl;
        }
}

    b=0;
cout<<endl;
    cout<<"\t -----------------------------------------"<<endl;
    cout<<"\t ---------program service mullyana cell---------"<<endl;
    cout<<"\t-------------------------------------------"<<endl;
    cout<<endl;
    cout<<"\t tekan 1. Flash/Install Ulang \t :Rp. 80.000"<<endl;
    cout<<"\t tekan 2. Ganti Konektor casan \t :Rp. 50.000"<<endl;
    cout<<"\t tekan 3. Ganti dudukan headset  :Rp. 50.000"<<endl;
    cout<<"\t tekan 4. Ganti LCD \t\t :Rp. 150.000"<<endl;
    cout<<"\t tekan 5. Ganti TC \t\t :Rp. 150.000"<<endl;
    cout<<"\t tekan 6. Ganti LCD dan TC \t :Rp. 300.000"<<endl;
    cout<<"\t tekan 7. Bypass Account Google  :Rp. 125.000"<<endl;
    cout<<"\t tekan 8. Imei Null \t\t :Rp. 75.000"<<endl;
    cout<<"\t tekan 9. Ganti Speaker \t :Rp. 50.000"<<endl;
    cout<<"\t tekan 10. Ganti Custom Rom \t :Rp. 85.000"<<endl;
    cout<<"\t tekan 11. lC Emmc \t\t :Rp. 300.000"<<endl;
    cout<<"\t tekan 12. Ic TF \t\t :Rp. 150.000"<<endl;
    cout<<"\t tekan 13. Ic RF \t\t :Rp. 150.000"<<endl;
    cout<<"\t tekan 14. Ic Audio \t\t :Rp. 150.000"<<endl;
    cout<<"\t tekan 15. Ganti Ic Power \t :Rp. 250.000"<<endl;
    cout<<"\t tekan 16. Dual GSM-kan \t :Rp. 75.000"<<endl;
    cout<<"\t tekan 17. Kartu tidak kebaca \t :RP. 30.000"<<endl;
    cout<<"\t tekan 18. Sinyal hilang \t :Rp. 100.000"<<endl;
    cout<<"\t tekan 19. Ganti tombol volume \t :Rp. 25.000 "<<endl;
    cout<<"\t tekan 20. Ganti tombol power \t :Rp. 50.000"<<endl;
    cout<<"\t tekan 21. Kamera Blurr \t :Rp. 150.000"<<endl;
    cout<<"\t tekan 22. Ganti Vibrator \t :Rp. 25.000"<<endl;
    cout<<"\t tekan 23. Ganti Mikrophone \t :Rp. 25.000"<<endl;
    cout<<"\t tekan 24. Ganti batre \t\t :Rp. 150.000"<<endl;
    cout<<"\t tekan 25. Terkunci akun MI \t :Rp. 150.000"<<endl;
    cout<<"\t tekan 26. Mati total \t\t :Rp. 300.000"<<endl;
    int flash=80000;
    int konektor=50000;
    int headset=50000;
    int lcd=150000;
    int tc=105000;
    int lcd_tc=300000;
    int account_google=125000;
    int imei=75000;
    int speaker=50000;
    int rom=85000;
    int emmc=300000;
    int ic_tf=150000;
    int ic_rf=150000;
    int ic_audio=150000;
    int ic_power=250000;
    int gsm=75000;
    int kartu_sim=30000;
    int sinyal_hilang=100000;
    int volume=25000;
    int power=50000;
    int kamera_blur=150000;
    int vibrator=25000;
    int mikrophone=25000;
    int batre=150000;
    int akun_mi=150000;
    int pilihan2=0;
    int matot=300000;
    cout<<endl;
    for(a=0;a<25;a++){
        cout<<"\t Masukkan kerusakan handphone anda [1-26] :";
            cin>>pilihan2;
        switch(pilihan2){
            case 1:
                cout<<"\t Masukkan jumlah handphone yang di flash :";
                cin>>c;
                count[a]=c;
                cout<<endl;
                jumlah[a]=c*flash;
                jenis[a]=1;
                break;

            case 2:
                cout<<"\t Masukkan jumlah handphone yang akan diganti konektor casan:";
                cin>>c;
                count[a]=c;
                jumlah[a]=c*konektor;
                jenis[a]=2;
                break;

            case 3:
                cout<<"\t Masukkan jumlah handphone yang rusak lubang hebsetnya :";
                cin>>c;
                count[a]=c;
                jumlah[a]=c*headset;
                jenis[a]=3;
                break;
            case 4:
                cout<<"\t Masukan jumalh handphone yang di ganti LCD :";
                cin>>c;
                count[a]=c;
                jumlah[a]=c*lcd;
                jenis[a]=4;
                break;
            case 5:
                cout<<"\t Masukan jumalh handphone yang di ganti TC :";
                cin>>c;
                count[a]=c;
                jumlah[a]=c*tc;
                jenis[a]=5;
                break;
            case 6:
                cout<<"\t Masukan jumlah handphone yang di ganti LCD & TC :";
                cin>>c;
                count[a]=c;
                jumlah[a]=c*lcd_tc;
                jenis[a]=6;
                break;
            case 7:
                cout<<"\t Masukan jumlah handphone yang akan di bypass account google :";
                cin>>c;
                count[a]=c;
                jumlah[a]=c*account_google;
                jenis[a]=7;
                break;
            case 8:
                cout<<"\t Masukan jumlah handphone yang imei Null :";
                cin>>c;
                count[a]=c;
                jumlah[a]=c*imei;
                jenis[a]=8;
                break;
            case 9:
                cout<<"\t Masukan jumlah handphone yang di ganti speaker :";
                cin>>c;
                count[a]=c;
                jumlah[a]=c*speaker;
                jenis[a]=9;
                break;
            case 10:
                cout<<"\t Masukan jumlah handphone yang di ganti ROM :";
                cin>>c;
                count[a]=c;
                jumlah[a]=c*rom;
                jenis[a]=10;
                break;
            case 11:
                cout<<"\t Masukan jumlah handphone yang di ganti IC EMMC :";
                cin>>c;
                count[a]=c;
                jumlah[a]=c*emmc;
                jenis[a];
                break;
            case 12:
                cout<<"\t Masukan jumlah handphone yang di ganti IC TF :";
                cin>>c;
                count[a]=c;
                jumlah[a]=c*ic_tf;
                jenis[a]=12;
                break;
            case 13:
                cout<<"\t Masukan jumlah handphone yang diganti IC RF :";
                cin>>c;
                count[a]=c;
                jumlah [a]=c*ic_rf;
                jenis[a]=13;
                break;
            case 14:
                cout<<"\t Masukan jumlah handphone yang diganti IC AUDIO :";
                cin>>c;
                count[a]=c;
                jumlah[a]=c*ic_audio;
                jenis[a]=14;
                break;
            case 15:
                cout<<"\t Masukan jumlah handphone yang diganti IC POWER:";
                cin>>c;
                count[a]=c;
                jumlah[a]=c*ic_power;
                jenis[a]=15;
                break;
            case 16:
                cout<<"\t Masukan jumlah handphone yang akan di GSM-kan :";
                cin>>c;
                count[a]=c;
                jumlah[a]=c*gsm;
                jenis[a]=16;
                break;
            case 17:
                cout<<"\t Masukan jumlah handphone yang akan diganti slot sim :";
                cin>>c;
                count[a]=c;
                jumlah[a]=c*kartu_sim;
                jenis[a]=17;
                break;
            case 18:
                cout<<"\t Maaukan jumlah handphone yang sinyal hilang :";
                cin>>c;
                jumlah[a]=c*sinyal_hilang;
                jenis[a]=18;
                break;
            case 19:
                cout<<"\t Masukan jumlah handphone yang ganti tombol volume :";
                cin>>c;
                count[a]=c;
                jumlah[a]=c*volume;
                jenis[a]=19;
                break;
            case 20:
                cout<<"\t Masukan jumlah handphone yang ganti tombol power :";
                cin>>c;
                count[a]=c;
                jumlah[a]=c*power;
                jenis[a]=20;
                break;
            case 21:
                cout<<"\t Masukan jumlah handphone yang kamera blur ";
                cin>>c;
                count[a]=c;
                jumlah[a]=c*kamera_blur;
                jenis[a]=21;
                break;
            case 22:
                cout<<"\t Masukan jumlah handphone yang getar tidak berfungsi :" ;
                cin>>c;
                count[a]=c;
                jumlah[a]=c*vibrator;
                jenis[a]=22;
                break;
            case 23:
                cout<<"\t Masukan jumlah handphone yang mikrophone tidak berfungsi :";
                cin>>c;
                count[a]=c;
                jumlah[a]=c*mikrophone;
                jenis[a]=23;
                break;
            case 24:
                cout<<"\t Masukan jumlah handphone yang ganti batre :";
                cin>>c;
                count[a]=c;
                jumlah[a]=c*batre;
                jenis[a]=24;
                break;
            case 25:
                cout<<"\t Masukan jumlah handphone yang terkunci Akun Micloud :";
                cin>>c;
                count[a]=c;
                jumlah[a]=c*akun_mi;
                jenis[a];
                break;
            case 26:
                cout<<"\t Masukan jumlah handphone yang matot :";
                cin>>c;
                count[c]=c;
                jumlah[a]=c*matot;
                jenis[a]=26;
                break;

            default:
                cout <<"\t Merek handphone anda tak ada";
                break;
        }
b=b+1;
        cout<<endl;
        cout<<"\t Apakah anda ingin service handphone lagi ? [y/t]";
        cin>>lanjut;
        cout<<endl;

        if(lanjut=='t'){
            break;
        }
    }
    for(a=0;a<b;a++){
        cout<<"\t Merek handphone \t\t : ";

            if(jenis[a]==1){
                cout<<"SAMSUNG"<<endl;
            }
            else if(jenis[a]==2){
                cout<<"XIAOMI"<<endl;
            }
            else if (jenis[a]==3){
                cout<<"HUAWEI"<<endl;
            }
            else if (jenis[a]==4){
                cout<<"OPPO"<<endl;
            }
            else if (jenis[a]==5){
                cout<<"ADVAN"<<endl;
            }
            else if (jenis[a]==6){
                cout<<"POLYTRON"<<endl;
            }
            else if (jenis[a]==7){
                cout<<"EVERCOSS"<<endl;
            }
            else if (jenis[a]==8){
                cout<<"SMARFREN"<<endl;
            }
            else if (jenis[a]==9){
                cout<<"IPHONE"<<endl;
            }
            else if (jenis[a]==10){
                cout<<"ZYREX"<<endl;
            }
            else if (jenis[a]==11){
                cout<<"HIMAX"<<endl;
            }
            else if (jenis[a]==12){
                cout<<"ACER"<<endl;
            }
            else if (jenis[a]==13){
                cout<<"ASUS"<<endl;
            }
            else if (jenis[a]==14){
                cout<<"COLLPAD"<<endl;
            }
            else if (jenis[a]==15){
                cout<<"LENOVO"<<endl;
            }
            else if (jenis[a]==16){
                cout<<"LG"<<endl;
            }
            else if (jenis[a]==17){
                cout<<"MEIZU"<<endl;
            }
            else if (jenis[a]==18){
                cout<<"NOKIA"<<endl;
            }
            else if (jenis[a]==19){
                cout<<"NEXIAN"<<endl;
            }
            else if (jenis[a]==20){
                cout<<"SHARP"<<endl;
            }
            else if (jenis[a]==21){
                cout<<"SONY"<<endl;
            }
            else if (jenis[a]==22){
                cout<<"VIVO"<<endl;
            }
            else if (jenis[a]==23){
                cout<<"WIKO"<<endl;
            }
            else if (jenis[a]==24){
                cout<<"ZTE"<<endl;
            }
            else if (jenis[a]==25){
                cout<<"OCEPLUS"<<endl;
            }
            else if (jenis[a]==26){
                cout<<"ALCATEL"<<endl;
            }
            else if (jenis[a]==27){
                cout<<"MITO"<<endl;
            }
            else if (jenis[a]==28){
                cout<<"ALDO"<<endl;
            }

            else{
                cout<<"xiomi"<<endl;
            }

        cout<<"\t Jumlah barang \t\t\t : "<<count[a]<<endl;
        cout<<"\t Total harga \t\t\t : "<<jumlah[a]<<" "<<endl;
    }

    int total=transaksi(jumlah,b);
    cout<<"\t Duit nu kudu dibayar \t\t :Rp. "<<total<<" rupiah"<<endl;

    cout<<"\t Uang ente \t\t\t :Rp.";
    cin>>bayar;

    if(bayar<total){
        cout<<"Uangmu tidak mencukupi yang harus dibayar semest ";
    }
    else{
        cout<<"\t Duit pulangan ente sebesar \t :Rp. "<<bayar-total<<" rupiah"<<endl;

        cout<<endl;

        cout<<"-------------------------------------------------------------------------"<<endl;
        cout<<"===========  Hatur nuhun parantos percanteun MULYANA Cell  =============="<<endl;
        cout<<"-------------------------------------------------------------------------"<<endl;
    }
    getch();

}
=======================================================



ini hasilnya
 gambar 1.1 hasil inputan merek hp


 gambar 1.2 menginput kerusakan hp

gambar 1.3 hasil inputannya




sekian semoga ini dapat bermanfaat bisa juga download file source code nya disini.

Subscribe to receive free email updates:

0 Response to "Program penggabungan switch case, looping dan function C++ Menggunakan KodeBlocks"