Untitled

Run Settings
LanguageC++
Language Version
Run Command
#include <iostream.h> #include <stdio.h> #include <string.h> using namespace std; /* Nama : muhamad nibroos najib Nim : 1620230014 Prodi : Matematika UTS */ void main (){ kepala: char nmpmsan[20], nmakrt[22], nmakls[23], kdekrt[20], lgi; int kdekls, jmlhtkt, hrgtkt, ubyr; float ttl, grndttl, dc, btmbhn, ukmbl; clrscr(); cout<<"---------------------------------------------------------------------------"<<endl; cout<<"\t\t\t PROGRAM TIKET KERETA"<<endl; cout<<"---------------------------------------------------------------------------"<<endl; cout<<" Kelas \t AG<Argo Bromo> \t AL<Argo Lawu> PH<Argo Wilis>"<<endl; cout<<"---------------------------------------------------------------------------"<<endl; cout<<"1-Executive 500.000 \t\t 475.000 450.000"<<endl; cout<<"2-Bisnis 480.000 \t\t 455.000 430.000"<<endl; cout<<"3-Ekonomi 460.000 \t\t 435.000 410.000"<<endl; cout<<"---------------------------------------------------------------------------"<<endl; cout<<"Ketentuan Discount:"<<endl; cout<<"Apabila pembelian tiket diatas 10 maka diskon 10% dari Total"<<endl; cout<<"Apabila pembelian tiket diatas 5 maka diskon 5% dari Total"<<endl; cout<<"---------------------------------------------------------------------------"<<endl; cout<<"Ketentuan Biaya Tambahan:"<<endl; cout<<"Kelas Executive adalah 3% dari Total"<<endl; cout<<"Kelas Bisnis adalah 2% dari Total"<<endl; cout<<"Kelas Ekonomi adalah 1% dari Total"<<endl; cout<<"---------------------------------------------------------------------------"<<endl; cout<<"Ketentuan Salah Input:"<<endl; cout<<"Jika input Kode Kereta ATAU Kode Kelas salah maka muncul pesan."<<endl; cout<<"Setelah muncul pesan lalu pertanyaan ingin input lagi."<<endl; cout<<"---------------------------------------------------------------------------"<<endl; cout<<"Ketentuan Kondisi:"<<endl; cout<<"Program harus menggunakan switch case dan if else <Posisi Bebas>."<<endl; cout<<"---------------------------------------------------------------------------"<<endl; cout<<"Nama Pemesan : ";cin>>nmpmsan; cout<<"Masukan Kode Kereta [AG/AL/PH]: ";cin>>kdekrt; cout<<"Masukan Kode Kelas [1/2/3] : ";cin>>kdekls; if (strcmp (kdekrt, "AG") == 0 || strcmp (kdekrt, "ag") == 0){ strcpy (nmakrt,"Argo Bromo"); if (kdekls == 1){ strcpy (nmakls,"Executive"); hrgtkt = 500000; } else if (kdekls == 2){ strcpy (nmakls,"Bisnis"); hrgtkt = 480000; } else if (kdekls == 3){ strcpy (nmakls,"Ekonomi"); hrgtkt = 460000; } else{ cout<<"---------------------------------------------------------------------------"<<endl; cout<<"Kode yang anda masukan salah"<<endl; cout<<"Ingin input lagi [Y/T] ";cin>>lgi; switch (lgi){ case 'Y': case 'y': goto kepala; default: goto kaki; } } } else if (strcmp (kdekrt, "AL") == 0 || strcmp (kdekrt, "al") == 0){ strcpy (nmakrt,"Argo Lawu"); if (kdekls == 1){ strcpy (nmakls,"Executive"); hrgtkt = 475000; } else if (kdekls == 2){ strcpy (nmakls,"Bisnis"); hrgtkt = 455000; } else if (kdekls == 3){ strcpy (nmakls,"Ekonomi"); hrgtkt = 435000; } else{ cout<<"---------------------------------------------------------------------------"<<endl; cout<<"Kode yang anda masukan salah" << endl; cout<<"Ingin input lagi [Y/T] "; cin >> lgi; switch (lgi){ case 'Y': case 'y': goto kepala; default: goto kaki; } } } else if (strcmp (kdekrt, "PH") == 0 || strcmp (kdekrt, "ph") == 0){ if (kdekls == 1){ strcpy (nmakls,"Executive"); hrgtkt = 450000; } else if (kdekls == 2){ strcpy (nmakls,"Bisnis"); hrgtkt = 430000; } else if (kdekls == 3){ strcpy (nmakls,"Ekonomi"); hrgtkt = 410000; } else{ cout<<"---------------------------------------------------------------------------"<<endl; cout<<"Kode yang anda masukan salah"<<endl; cout<<"Ingin input lagi [Y/T] ";cin>>lgi; switch (lgi){ case 'Y': case 'y': goto kepala; default: goto kaki; } } } else{ cout<<"---------------------------------------------------------------------------"<<endl; cout<<"Kode yang anda masukan salah."<<endl; cout<<"Ingin input lagi [Y/T] ";cin>>lgi; switch (lgi){ case 'Y': case 'y': goto kepala; default: goto kaki; } } clrscr(); cout<<"\t\t\t DAFTAR PEMESAN KERETA "<<endl; cout<<"---------------------------------------------------------------------------"<<endl; cout<<"Nama Pemesan : "<<nmpmsan<<endl; cout<<"Kode Kereta : "<<kdekrt<<endl; cout<<"Kode Kelas : "<<kdekls<<endl; cout<<"Nama Kereta : "<<nmakrt<<endl; cout<<"Nama Kelas : "<<nmakls<<endl; cout<<"Harga Tiket : "<<hrgtkt<<endl; cout<<"Jumlah Beli : ";cin>>jmlhtkt; ttl = hrgtkt * jmlhtkt; printf ("Total :Rp. %8.2f \n",ttl); if (jmlhtkt > 10){ dc = 0.1 * ttl; } else if (jmlhtkt > 5){ dc = 0.05 * ttl; } else{ dc = 0; } printf ("Discount :Rp. %8.2f \n",dc); if (kdekls == 1){ btmbhn = 0.03 * ttl; } else if (kdekls == 2){ btmbhn = 0.02 * ttl; } else if (kdekls == 3){ btmbhn = 0.01 * ttl; } else{ btmbhn = 0; } printf ("Biaya Tambahan :Rp. %8.2f \n",btmbhn); cout<<"---------------------------------------------------------------------------"<<endl; grndttl = ttl + btmbhn - dc; printf ("Grand Total :Rp. %8.2f \n",grndttl); cout<< "Uang Bayar :Rp. ";cin>>ubyr; ukmbl = ubyr-grndttl; printf ("Uang Kembali :Rp. %8.2f \n",ukmbl); cout<<"---------------------------------------------------------------------------"<<endl; cout<<"Ingin input lagi [Y/T] ";cin>>lgi; switch (lgi){ case 'Y': case 'y': goto kepala; default: goto kaki; } kaki : clrscr(); cout<<"---------------------------------------------------------------------------"<<endl; cout<<"TERIMAKASIH"<<endl; cout<<"---------------------------------------------------------------------------"<<endl; getch(); } return 0; }
Editor Settings
Theme
Key bindings
Full width
Lines