Popular Post

Popular Posts

About

Jumat, 05 Oktober 2018

Kali ini saya akan membuat sebuah program pembelian tiket pesawat yang menggunakan sebuah aplikasi Program C++ mobile yaitu Cxxdroid disini saya menggunakan perintah input & output untuk membuat program ini.

Berikut adalah contoh source code untuk menjalankan program:

#include <iostream>
#include <conio.h>
using namespace std;

int main()
{
    int kelas,jumlah,total;
    char kodepesawat[3],namapesawat[15],konfir;
    long harga;
 
    awal:
    clrscr();
 
    cout<<"\t\t\tPROGRAM TIKET PESAWAT"<<endl;
    cout<<"\t\t            JAKARTA-BALI"<<endl;
    cout<<"================================================================"<<endl;
 
    cout<<"\t MASUKAN KODE PESAWAT [GRD/BTK/CTL]"<<endl;
    cout<<"\t KODE PESAWAT = ";
    cin>>kodepesawat;
    cout<<endl;
    cout<<"----------------------------------------------------------------"<<endl;
 
    cout<<"\t KELAS PESAWAT"<<endl;
    cout<<"\t\t 1. EXECUTIVE"<<endl;
    cout<<"\t\t 2. BISNIS"<<endl;
    cout<<"\t\t 3. EKONOMI"<<endl;
    cout<<"----------------------------------------------------------------"<<endl;
    cout<<endl;
 
    cout<<"\t PILIH KELAS [1/2/3] = ";
    cin>>kelas;
    cout<<endl;
    cout<<"----------------------------------------------------------------"<<endl;
 
    if((strcmp(kodepesawat,"GRD")==0)||(strcmp(kodepesawat,"grd")==0))
    {
        strcpy(namapesawat,"GARUDA AIRLINES");
        if(kelas==1)
        {
            harga=1500000;
        }
        else if(kelas==2)
        {
            harga=900000;
        }
        else if(kelas==3)
        {
            harga=500000;
        }
        else{
            cout<<" KODE YANG ANDA MASUKAN SALAH";
            harga=0;
            return 0;
        }
    }
 
 
    else if((strcmp(kodepesawat,"BTK")==0)||(strcmp(kodepesawat,"btk")==0))
    {
        strcpy(namapesawat,"BATIK AIRLINES");
        if(kelas==1)
        {
            harga=1200000;
        }
        else if(kelas==2)
        {
            harga=800000;
        }
        else if(kelas==3)
        {
            harga=400000;
        }
        else{
            cout<<" KODE YANG ANDA MASUKAN SALAH";
            harga=0;
            return 0;
        }
    }
 
 
    if((strcmp(kodepesawat,"CTL")==0)||(strcmp(kodepesawat,"ctl")==0))
    {
        strcpy(namapesawat,"CITY LINK AIRLINES");
        if(kelas==1)
        {
            harga=1000000;
        }
        else if(kelas==2)
        {
            harga=700000;
        }
        else if(kelas==3)
        {
            harga=300000;
        }
        else{
            cout<<" KODE YANG ANDA MASUKAN SALAH";
            harga=0;
            return 0;
        }
    }
 
    cout<<"\t NAMA PESAWAT = "<<namapesawat<<endl;
    cout<<"\t HARGA TIKET  = "<<harga<<endl;
    cout<<"\t JUMLAH TIKET = ";
    cin>>jumlah;
 
    total=harga*jumlah;
    cout<<"\t TOTAL BAYAR  = "<<total<<endl;
    cout<<"----------------------------------------------------------------"<<endl;
 
    cout<<endl;
    cout<<"INGIN INPUT LAGI [Y/T]:";
    cin>>konfir;
 
    if(konfir=='Y'||konfir=='y'){
        goto awal;
    }
    else
    {
        return 0;
    }
 
    getch();
 
}


Ket :
1. Menggunakan Input dan Output ( std::cin & std::cout )
2. Menggunakan Nested If
3. Rumus Total bayar, totalbayar=harga*jumlah


Berikut adalah contoh hasil program setelah di running




{ 1 komentar... read them below or add one }

- Copyright © UBSI Jatiwaringin - Devil Survivor 2 - Powered by Blogger - Designed by Johanes Djogan -