//Deklarasi Header #include<iostream.h> #include<stdio.h> #include<conio.h> main() { //Deklarasi Variabel struct { char kd_jen_pak,*paket,kd_jen_atr,*atraksi, *bonus; long hrg_paket, hrg_atraksi, diskon; }resto; char nama[25], lagi; int bayar, total,u_bayar,u_kembali; atas: //Deklarasi Input clrscr(); cout<<" BIRTHDAY PARTY 4 U "<<endl; cout<<"------------------------------------------------"<<endl; cout<<"Nama Pemesan : ";gets(nama); cout<<endl; ulangkd_jen_pak: cout<<"Jenis Paket"<<endl; cout<<"[1]Paket Mewah, harga Rp 2.000.000,-"<<endl; cout<<"[2]Paket Sedang, harga Rp 1.500.000,-"<<endl; cout<<"[3]Paket Sederhana,harga Rp 1.000.000,-"<<endl; cout<<"Jenis paket yang di pilih [1/2/3] : ";cin>>resto.kd_jen_pak; cout<<endl; ulangkd_jen_atr: cout<<"[B]Badut, Harga Rp 300.000,-"<<endl; cout<<"[P]Sulap, Harga Rp 500.000,-"<<endl; cout<<"[S]Penyanyi Cilik, Harga Rp 600.000,-"<<endl; cout<<"Jenis Atraksi yang di pilih [B/P/S] : ";cin>>resto.kd_jen_atr; //Deklarasi Percabangan switch(resto.kd_jen_pak) { case '1': {resto.hrg_paket=2000000; resto.paket="Paket Mewah";} break; case '2': {resto.hrg_paket=1500000;resto.paket="Paket Sedang";} break; case '3': {resto.hrg_paket=1000000;resto.paket="Paket Sederhana";} break; default: cout<<"Jenis Paket salah..!"<<endl; goto ulangkd_jen_pak; break; } switch(resto.kd_jen_atr) { case 'B': case 'b': {resto.hrg_atraksi=300000;resto.atraksi="Badut";} break; case 'P': case 'p': {resto.hrg_atraksi=500000;resto.atraksi="Sulap";} break; case 'S': case 's': {resto.hrg_atraksi=600000;resto.atraksi="Penyanyi Cilik";} break; default: cout<<"Jenis Atraksi salah..!"<<endl; goto ulangkd_jen_atr; break; } total=resto.hrg_atraksi+resto.hrg_paket; if(total>=2000000) {resto.diskon=0.1*total;resto.bonus="Black Forest";} else {resto.diskon=0;resto.bonus="Maaf Tidak Dapat Bonus";} bayar=total-resto.diskon; clrscr(); cout<<" BIRTHDAY PARTY 4 U"<<endl; cout<<"---------------------------------------"<<endl; cout<<"Nama Pemesan : "<<nama<<endl; cout<<"Paket Pilihannya Adalah : "<<resto.paket<<endl; cout<<"Harga Per-Paket : "<<resto.hrg_paket<<endl; cout<<"Atraksi Pilihan : "<<resto.atraksi<<endl; cout<<"Harga Atraksi : "<<resto.hrg_atraksi<<endl; cout<<"---------------------------------------"<<endl; cout<<"Bonus : "<<resto.bonus<<endl; cout<<"---------------------------------------"<<endl; cout<<"Total Keseluruhan : "<<total<<endl; cout<<"Potongan yang diperoleh : "<<resto.diskon<<endl; cout<<"Total Bayar : "<<bayar<<endl; cout<<"Uang Bayar : ";cin>>u_bayar; u_kembali=u_bayar-bayar; cout<<"Uang Kembali : "<<u_kembali<<endl; cout<<"---------------------------------------"<<endl; cout<<"Mau Input Data Lagi[Y/T]:";cin>>lagi; if(lagi=='y'||lagi=='Y') {goto atas;} getch(); }
Contoh Structure & Switch-case
Posted In
12.1C.07,
Algoritma dan Pemrograman,
BSI,
Semester I
- 6/09/2012 - 0
comments
Program Perhitungan Gaji
Posted In
12.1C.07,
Algoritma dan Pemrograman,
BSI,
C++,
Quiz,
Semester I
- 6/06/2012 - 0
comments
//Deklarasi Header #include<stdio.h> #include<iostream.h> #include<conio.h> main() { //Deklarasi Struct & Variable struct { char kd_jab,*jabatan,kd_status,*status; long gapok, tunjangan; }gaji; char tanggal[20],nip[6], nama[25]; long total; //Deklarasi Input cout<<" DAFTAR GAJI KARYAWAN "<<endl; cout<<" PT.NGALOR NGIDUL "<<endl; cout<<endl; cout<<"Tanggal : ";gets(tanggal); cout<<endl; cout<<"NIP : ";cin>>nip; cout<<"Nama Karyawan : ";gets(nama); ulang_kd_jab: cout<<"Kode Jabatan [1/2] : ";cin>>gaji.kd_jab; ulang_kd_status: cout<<"Kode Status [M/S] : ";cin>>gaji.kd_status; //Deklarasi Percabangan if (gaji.kd_jab == '1') { gaji.jabatan = "Administrasi"; gaji.gapok = 800000; if (gaji.kd_status == 'M' || gaji.kd_status == 'm') { gaji.status = "Menikah"; gaji.tunjangan = 200000; } else if (gaji.kd_status == 'S' || gaji.kd_status == 's') { gaji.status = "Single"; gaji.tunjangan = 100000; } else { cout << "Kode status salah...!"<<endl; goto ulang_kd_status;} } else if (gaji.kd_jab == '2') { gaji.jabatan = "Operasional"; gaji.gapok = 850000; if (gaji.kd_status == 'M' || gaji.kd_status == 'm') { gaji.status = "Menikah"; gaji.tunjangan = 250000; } else if (gaji.kd_status == 'S' || gaji.kd_status == 's') { gaji.status = "Single"; gaji.tunjangan = 150000; } else { cout << "Kode status salah...!"<<endl; goto ulang_kd_status;} } else { cout << "Kode jabatan salah...!"<<endl; goto ulang_kd_jab;} total = gaji.gapok + gaji.tunjangan; //Deklarasi output clrscr(); cout<<" DAFTAR GAJI KARYAWAN "<<endl; cout<<" PT.NGALOR NGIDUL "<<endl; cout<<endl; cout<<"Tanggal : "<<tanggal<<endl; cout<<"===================================="<<endl; cout<<"NIP : "<<nip<<endl; cout<<"Nama Karyawan : "<<nama<<endl; cout<<"Kode Jabatan : "<<gaji.kd_jab<<endl; cout<<"Jabatan : "<<gaji.jabatan<<endl; cout<<"Gaji pokok : "<<gaji.gapok<<endl; cout<<"Kode Status : "<<gaji.kd_status<<endl; cout<<"Status pegawai : "<<gaji.status<<endl; cout<<"Tunjangan : "<<gaji.tunjangan<<endl; cout<<"Total : "<<total; getch(); }
Latihan Soal PTIK Pert 13 Quiz
Posted In
12.1C.07,
BSI,
PTIK,
Quiz,
Semester I
- 6/04/2012 - 0
comments
Started on | Monday, 4 June 2012, 02:27 PM |
---|---|
Completed on | Monday, 4 June 2012, 02:31 PM |
Time taken | 3 mins 49 secs |
Marks | 10.00/10.00 |
Grade | 100.00 out of a maximum of 100.00 |
Latihan Soal PTIK Pert 12 Quiz
Posted In
12.1C.07,
BSI,
PTIK,
Quiz,
Semester I
- 6/04/2012 - 0
comments
Started on | Monday, 4 June 2012, 10:09 AM |
---|---|
Completed on | Monday, 4 June 2012, 10:12 AM |
Time taken | 2 mins 38 secs |
Marks | 10.00/10.00 |
Grade | 100.00 out of a maximum of 100.00 |
Subscribe to:
Posts (Atom)