Program Pembelian Tiket Kereta Api C++

full-width



#include <iostream>
#include <conio.h>
#include <string.h> 

using namespace std;

/*Prosedur*/
    void judul(){
        cout<<"\t\t||\t PROGRAM TIKET KERETA API \t||\n";
        cout<<"\t\t==========================================\n\n";
    }
    
/*Program Utama*/
int main()
{
    system("color a");
    char nk[23],np[23],kd[23],lagi;
    int harga,kls,jml,pb,ub,uk;

    judul();//memanggil prosedur

    cout<<"\t\t\t     TUJUAN"<<endl;
    cout<<"\tA = Blitar(BL)"<<"\t\t-\t"<<"Surabaya Gubeng(SGU)"<<"\t| KA PENATARAN"<<endl;
    cout<<"\tB = Blitar(BL)"<<"\t\t-\t"<<"Malang(ML)"<<"\t\t| MALIOBORO EKSPRES"<<endl;
    cout<<"\tC = Wonokromo(WO)"<<"\t-\t"<<"Blitar(BL)"<<"\t\t| KA DHOHO"<<endl;
    cout<<"\tMasukan Tujuan[A/B/C]:\t";cin>>kd;
    cout<<"\n\tPilihan  kelas [1/2/3]:\n\n";
    cout<<"\t1.Eksekutif\n";
    cout<<"\t2.Bisnis\n";
    cout<<"\t3.Ekonomi\n\n";
    cout<<"\tMasukan kelas [1/2/3]:\t";cin>>kls;

atas:
    system("cls");
    cout<<"\t\t\tPROGRAM TIKET KERETA\n";
    cout<<"\t\t====================================\n\n";
    
/*Pengkondisian atau Percabangan*/
    if (strcmp(kd,"A")==0||strcmp(kd,"a")==0)
    {
    strcpy(nk,"KA Penataran");
    if(kls==1)
    harga=210000;
    else if(kls==2)
    harga=35000;
    else if(kls==3)
    harga=15000;
    }
    
    else if (strcmp(kd,"B")==0||strcmp(kd,"b")==0)
    {
    strcpy(nk,"Malioboro Ekspres");
    if(kls==1)
    harga=120000;
    else if(kls==2)
    harga=70000;
    else if(kls==3)
    harga=20000;
    }
    
    else if (strcmp(kd,"C")==0||strcmp(kd,"c")==0)
    {
    strcpy(nk,"KA Dhoho");
    if(kls==1)
    harga=210000;
    else if(kls==2)
    harga=35000;
    else if(kls==3)
    harga=15000;
    }
    else
    {
    
}
    cout<<"\tNama Pemesan\t\t\t:";cin>>np;
    cout<<"\tNama Kereta\t\t\t:"<<nk<<endl;
    cout<<"\tKelas Kereta\t\t\t:"<<kls<<endl;
    cout<<"\tHarga Tiket\t\t\t:Rp"<<harga<<endl;
    cout<<"\tJumlah Pemesanan Tiket\t\t:";
    cin>>jml;
    pb=harga*jml;
    cout<<"\tPembayaran\t\t\t:Rp"<<pb<<endl;
    
    cout<<"\t**********************************************\n\n";
    cout<<"\tTotal Pembayaran\t\t:Rp"<<pb<<endl;
    cout<<"\tUang Bayar\t\t\t:Rp";
    cin>>ub;
    uk=ub-pb;
    cout<<"\tUang Kembali\t\t\t:Rp"<<uk<<endl;
    
/*Perulangan*/
    cout<<"  \n\n\n\n\t\t\t\t    INGIN INPUT LAGI [Y/T]?:";cin>>lagi;    
    while(lagi=='Y'||lagi=='y'){
    goto atas;}
    
bawah:
{
    system("cls");
    cout<<"\n\n\n\n\n\t\t==================================\n ";
    cout<<"\t\t\t....TERIMAKASIH....\n ";
    cout<<"\t\t================================== ";
}
getch();
}


Hasil Program

0 Comments