Contoh Program Rental Mobil Menggunakan Bahasa C++


Assalamualaikum wr.wb,

WELCOME To my Blog, sudah lama nggak Nge-Post Gann ^_^ ..

Kali ini saya akan share Tugas C++ yang sempat bikin galauu :( . wkwkwk,,

langsung ajah, berikut Listingnya .. ^_^


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

using namespace std;
int main()
{
awal:
    int l_sewa;
    char nama [30];
    char pil,yt;
    cout << "        PROGRAM RENTAL MOBIL                                         " << endl;
        cout << " =============================================================================" << endl;
    cout << " |  KODE |       JENIS MOBIL             |         HARGA SEWA/HARI            |         " << endl;
cout << " ==============================================================================  " << endl;
    cout << " |  1.   |      MINI BUS                 |           Rp. 350.000              |        " << endl;
    cout << " |  2.   |      TOYOTA YARIS             |           Rp. 500.000              |        " << endl;
    cout << " |  3.   |      BMW                      |           Rp. 800.000              |        " << endl;
cout << " =============================================================================" << endl;
    cout << "                                                                              " << endl;
    cout << "            Nama                 :   " ;cin>>nama;
cout <<endl;
    cout << "            Kode Mobil (1/2/3)   :  " ;cin>>pil;
cout <<endl;
    cout << "            Lama Sewa            :  " ;cin>>l_sewa;
    system("cls");

    switch (pil)
    {
    case '1':cout << "              ===== MINI BUS =====     " <<endl;
cout<<endl;
        {
    int h_sewa,sub_tot,diskon,tot,byr,kmbl;
h_sewa=350000;
    sub_tot=l_sewa*h_sewa;
if (l_sewa>=14) (diskon=sub_tot*0.3);
else (diskon=sub_tot*0);
tot=sub_tot-diskon;
cout << "   Nama Penyewa         : " <<nama<< endl;
cout <<endl;
cout << "   Kode Mobil (1/2/3)   : " <<pil<< endl;
cout <<endl;
cout << "   Jenis Mobil          : " <<"MINI BUS"<< endl;
cout <<endl;
cout << "   Harga Sewa/Hari      : " <<h_sewa<< endl;
cout <<endl;
    cout << "   Lama peminjaman      : " <<l_sewa<<" hari"<< endl;
cout <<endl;
    cout << "   Sub Total            : Rp " <<sub_tot<<",-"<< endl;
cout <<endl;
cout << "   Diskon               : Rp " <<diskon<<",-"<< endl;
cout <<endl;
    cout << "   Total Bayar          : Rp " <<tot<<",-"<< endl;
cout <<endl;
cout <<endl;
cout << "  --------------------------------------------"<<endl;
cout << "   Uang Bayar           = Rp ";cin>>byr;
cout <<endl;
kmbl=byr-tot;
cout << "   Uang Kembalian       = Rp "<<kmbl<<endl;
cout <<endl;
cout <<"                                                  by : MUHAMMAD IKBAL MURSIDIN "<<endl;
        }
    break;
    }
    switch (pil)
    {
    case '2':cout << "        ===== TOYOTA YARIS =====    " <<endl;
cout <<endl;
        {
    int h_sewa,sub_tot,diskon,tot,byr,kmbl;
h_sewa=500000;
    sub_tot=l_sewa*h_sewa;
if (l_sewa>=14) (diskon=sub_tot*0.3);
else (diskon=sub_tot*0);
tot=sub_tot-diskon;
cout << "   Nama Penyewa         : " <<nama<< endl;
cout <<endl;
cout << "   Kode Mobil (1/2/3)   : " <<pil<< endl;
cout <<endl;
cout << "   Jenis Mobil          : " <<"TOYOTA YARIS"<< endl;
cout <<endl;
cout << "   Harga Sewa/Hari      : " <<h_sewa<< endl;
cout <<endl;
    cout << "   Lama peminjaman      : " <<l_sewa<<" hari"<< endl;
cout <<endl;
    cout << "   Sub Total            : Rp " <<sub_tot<<",-"<< endl;
cout <<endl;
cout << "   Diskon               : Rp " <<diskon<<",-"<< endl;
cout <<endl;
    cout << "   Total Bayar          : Rp " <<tot<<",-"<< endl;
cout <<endl;
cout << " --------------------------------------------"<<endl;
cout << "   Uang Bayar           = Rp ";cin>>byr;
cout <<endl;
kmbl=byr-tot;
cout << "   Uang Kembalian       = Rp "<<kmbl<<endl;
cout <<endl;
cout <<"                                                  by : MUHAMMAD IKBAL MURSIDIN "<<endl;

        }
    break;
    }
    switch (pil)
    {
    case '3':cout << "                 ===== BMW =====" <<endl;
cout <<endl;
        {
int h_sewa,sub_tot,diskon,tot,byr,kmbl;
h_sewa=80000;
    sub_tot=l_sewa*h_sewa;
if (l_sewa>=14) (diskon=sub_tot*0.3);
else (diskon=sub_tot*0);
tot=sub_tot-diskon;
cout << "   Nama Penyewa         : " <<nama<< endl;
cout <<endl;
cout << "   Kode Mobil (1/2/3)   : " <<pil<< endl;
cout <<endl;
cout << "   Jenis Mobil          : " <<"BMW"<< endl;
cout <<endl;
cout << "   Harga Sewa/Hari      : " <<h_sewa<< endl;
cout <<endl;
    cout << "   Lama peminjaman      : " <<l_sewa<<" hari"<< endl;
cout <<endl;
    cout << "   Sub Total            : Rp " <<sub_tot<<",-"<< endl;
cout <<endl;
cout << "   Diskon               : Rp " <<diskon<<",-"<< endl;
cout <<endl;
    cout << "   Total Bayar          : Rp " <<tot<<",-"<< endl;
cout <<endl;
cout << "  --------------------------------------------"<<endl;
cout << "   Uang Bayar           = Rp ";cin>>byr;
cout <<endl;
kmbl=byr-tot;
cout << "   Uang Kembalian       = Rp "<<kmbl<<endl;
cout <<endl;
cout <<"                                                  by : MUHAMMAD IKBAL MURSIDIN "<<endl;
cout <<endl;
cout <<endl;
        }
    break;
}
cout<<"      Mau Isi Data lagi ? [Y/T] : ";
cin>>yt;
cout<<endl;

if(yt=='Y' || yt=='y')
{goto awal;}
if(yt=='T' || yt=='t')
{goto selesai;}
selesai:
    getch();
}

Hasil Program :






Semoga Bermanfaat Gan !

Wassalamualaikum Wr.Wb 

1 Komentar