Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <conio.h>
- #include <iostream.h>
- #include <stdio.h>
- void main()
- {
- char nama[30], kode[10], keterangan[20];
- int ket, pemakaian, totalkriteria, total, bayar, kembalian;
- cout<<"\n\t\t\t\t\t\tTugas Switch Case"<<endl;
- cout<<"\n\tKode Pelanggan : ";
- cin>>kode;
- cout<<"\tNama Pelanggan : ";
- gets(nama);
- cout<<"\tKeterangan Pelanggan [1..3] : ";
- cin>>ket;
- cout<<"================================"<<endl;
- if(ket > 3){
- cout<<"Salah memasukkan kode";
- } else {
- switch(ket)
- {
- case 1 :
- cout<<"Rumah"<<endl;
- cout<<"Pemakaian : ";
- cin>>pemakaian;
- total = pemakaian * 1200;
- if(total >= 100000) {
- totalkriteria = total - (total * 0.07) ; }
- else if (total >= 50000) {
- totalkriteria = total - (total * 0.02) ; }
- else {
- totalkriteria = total; }
- break;
- case 2 :
- cout<<"Ruko"<<endl;
- cout<<"Pemakaian : ";
- cin>>pemakaian;
- total = pemakaian * 2000;
- if(total >= 100000) {
- totalkriteria = total - (total * 0.10) ; }
- else if (total >= 50000) {
- totalkriteria = total - (total * 0.05) ; }
- else {
- totalkriteria = total - (total * 0.03) ; }
- break;
- case 3 :
- cout<<"Perusahaan"<<endl;
- cout<<"Pemakaian : ";
- cin>>pemakaian;
- total = pemakaian * 35000;
- if (total >= 100000) {
- totalkriteria = total - (total * 0.12) ; }
- else if (total >= 50000) {
- totalkriteria = total - (total * 0.07) ; }
- else {
- totalkriteria = total - (total * 0.05) ; }
- break;
- default:
- break;
- }
- cout<<"Jumlah Bayar(sebelum diskon) : "<<total<<endl;
- cout<<"Jumlah Bayar(sesudah diskon) : "<<totalkriteria<<endl;
- cout<<"Masukan Jumlah Bayar : ";
- cin>>bayar;
- kembalian = bayar - totalkriteria;
- cout<<"Kembalian Pelanggan : "<<kembalian;
- }
- getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement