Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Program Tiket Kereta
- // Task No.2 file 066-P04B.pptx
- // Amrul Mubarak Harahap
- // 19T03 - 1901098
- #include <iostream>
- #include <string>
- #include <cstring>
- #include <iomanip>
- using namespace std;
- int main(){
- string namaKrt, kelasKrt, namaPemesan;
- char kodeKrt[5], ulang;
- int kelas, hargaTkt, jumlahPsn, pembayaran, total, diskon, biayaTambah, bayar, kembalian;
- menu:
- system("cls");
- cout << "\t\tPROGRAM TIKET KERETA" << endl;
- cout << "================================================" << endl;
- cout << "Masukkan kode kereta [MK/SH/AA]: "; cin >> kodeKrt;
- cout << "Pilihan Kelas\n";
- cout << "1. Executive" << endl;
- cout << "2. Bisnis" << endl;
- cout << "3. Ekonomi" << endl;
- cout << "Masukkan kelas kereta [1/2/3]: "; cin >> kelas;
- if(kelas == 1 || kelas == 2 || kelas == 3){
- goto daftar;
- } else {
- cout << "Kode kereta yang anda masukkan salah!" << endl;
- goto ulang;
- }
- ulang:
- cout << "\nIngin Input Lagi?(Y/T): "; cin >> ulang;
- if(ulang == 'Y' || ulang == 'y'){
- goto menu;
- } else {
- goto akhir;
- }
- daftar:
- system("cls");
- cout << "\t\tDAFTAR PEMESANAN TIKET KERETA" << endl;
- cout << "=========================================================" << endl;
- if(strcmp(kodeKrt, "MK") == 0 || strcmp(kodeKrt, "mk") == 0){
- namaKrt = "Mutiara Kencana";
- switch (kelas){
- case 1:
- kelasKrt = "Executive";
- hargaTkt = 70000;
- biayaTambah = 20000;
- case 2:
- kelasKrt = "Bisnis";
- hargaTkt = 60000;
- biayaTambah = 15000;
- case 3:
- kelasKrt = "Ekonomi";
- hargaTkt = 50000;
- biayaTambah = 10000;
- }
- } else if(strcmp(kodeKrt, "SH") == 0 || strcmp(kodeKrt, "sh") == 0){
- namaKrt = "Samudera Harapan";
- switch (kelas){
- case 1:
- kelasKrt = "Executive";
- hargaTkt = 80000;
- biayaTambah = 20000;
- case 2:
- kelasKrt = "Bisnis";
- hargaTkt = 70000;
- biayaTambah = 15000;
- case 3:
- kelasKrt = "Ekonomi";
- hargaTkt = 60000;
- biayaTambah = 10000;
- }
- } else if(strcmp(kodeKrt, "AA") == 0 || strcmp(kodeKrt, "aa") == 0){
- namaKrt = "Argo Asahan";
- switch (kelas){
- case 1:
- kelasKrt = "Executive";
- hargaTkt = 75000;
- biayaTambah = 20000;
- case 2:
- kelasKrt = "Bisnis";
- hargaTkt = 65000;
- biayaTambah = 15000;
- case 3:
- kelasKrt = "Ekonomi";
- hargaTkt = 55000;
- biayaTambah = 10000;
- }
- } else {
- cout << "Maaf, kode kereta Anda tidak ditemukan" << endl;
- goto ulang;
- }
- cout << "Nama Pemesan : ";cin >> namaPemesan;
- cout << "Nama Kereta : " << namaKrt << endl;
- cout << "Kelas Kereta : " << kelasKrt << endl;
- cout << "Harga per Tiket : Rp " << hargaTkt << endl;
- cout << "Jumlah Pemesanan : "; cin >> jumlahPsn;
- cout << "Biaya Tambahan Fasilitas: Rp " << biayaTambah << endl;
- pembayaran = jumlahPsn * hargaTkt;
- if(jumlahPsn > 3){
- diskon = jumlahPsn * (5*hargaTkt/100);
- } else {
- diskon = 0;
- }
- total = biayaTambah + pembayaran - diskon;
- cout << "Pembayaran : Rp " << pembayaran << endl;
- cout << "Diskon : Rp " << diskon << endl;
- cout << "========================================================" << endl;
- cout << "Nama Pemesan : " << namaPemesan << endl;
- cout << "Total Bayar : Rp " << total << endl;
- cout << "Uang Bayar : Rp "; cin >> bayar;
- kembalian = bayar -total;
- cout << "Uang Kembali : Rp " << kembalian << endl;
- cout << "\nIngin Input Lagi?(Y/T): "; cin >> ulang;
- if(ulang == 'Y' || ulang == 'y'){
- goto menu;
- } else {
- goto akhir;
- }
- akhir:
- cout << "\n\t\t***TERIMA KASIH***";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement