Contoh Aplikasi Program Penginapan (Abie Barokah) Menggunakan C++ ini juga memakai fungsi perulangan FOR (array). Penjelasan kegiatan ini ialah Petugas menginput customer yang tiba untuk menginap di penginapan, lalu custoer dapat menentukan kamar (harga berbeda) dan menentukan berapa usang customer menginap.
Berikut langkahnya :
1. buka aplikasi borland C++
2. PIlih file > New > text edit
3. Pastekan koding berikut :
#include<stdio.h>
#include<conio.h>
#include<iostream.h>
main()
{
char nape[20],nacus[20],pesan[10];
char kode;
int lamasewa,tgl;
long hargasewa,jumbar,diskon,total,ubay,ukem;
cout<<" PENGINAPAN ABIE BAROKAH,Inn"<<endl;
cout<<"============================"<<endl;
cout<<"Input Nama Petugas :";gets(nape);
cout<<"Input Nama Customer :";gets(nacus);
cout<<"Input Tanggal :";cin>>tgl;
cout<<"============================"<<endl;
cout<<"Pilih Kode Kamar[G/E/C] :";cin>>kode;
cout<<"Input Lama Sewa [hari] :";cin>>lamasewa;
if (kode=='G')
{
strcpy(pesan,"GARUDA");
hargasewa=300000;
}
else if (kode=='E')
{
strcpy(pesan,"ELANG");
hargasewa=250000;
}
else if (kode=='C')
{
strcpy(pesan,"CENDRAWASIH");
hargasewa=90000;
}
else
{
strcpy(pesan,"salah Kode");
hargasewa=0;
}
cout<<endl;
cout<<endl;
cout<<"====================================="<<endl;
cout<<"BUKTI PEMESANAN KAMAR"<<endl;
cout<<"PENGINAPAN ABIE BAROKAH,Inn"<<endl;
cout<<"====================="<<endl;
cout<<"Nama Petugas :"<<nape<<endl;
cout<<"Nama Customer :"<<nacus<<endl;
cout<<"Tanggal Check In :"<<tgl<<endl;
cout<<"======================================"<<endl;
cout<<"Nama Kamar Yg Dipesan :"<<pesan<<endl;
cout<<"Harga Sewa :"<<hargasewa<<endl;
cout<<"Lama Sewa :"<<lamasewa<<endl;
cout<<"------------------------------------"<<endl;
jumbar=hargasewa*lamasewa;
cout<<"Jumlah Bayar :"<<jumbar<<endl;
if (lamasewa=3)
diskon=(jumbar/100)*5;
else if (lamasewa=4)
diskon=(jumbar/100)*5;
else if (lamasewa>=5)
diskon=(jumbar/100)*10;
else
diskon=(jumbar*0);
cout<<"Diskon :"<<diskon<<endl;
cout<<"-----------------------------"<<endl;
total=jumbar-diskon;
cout<<"Total Bayar :"<<total<<endl;
cout<<"Uang Bayar :";cin>>ubay;
ukem=ubay-total;
cout<<"Uang Kembalian :"<<ukem<<endl;
cout<<"----------------------------------------------"<<endl;
getch();
}
#include<conio.h>
#include<iostream.h>
main()
{
char nape[20],nacus[20],pesan[10];
char kode;
int lamasewa,tgl;
long hargasewa,jumbar,diskon,total,ubay,ukem;
cout<<" PENGINAPAN ABIE BAROKAH,Inn"<<endl;
cout<<"============================"<<endl;
cout<<"Input Nama Petugas :";gets(nape);
cout<<"Input Nama Customer :";gets(nacus);
cout<<"Input Tanggal :";cin>>tgl;
cout<<"============================"<<endl;
cout<<"Pilih Kode Kamar[G/E/C] :";cin>>kode;
cout<<"Input Lama Sewa [hari] :";cin>>lamasewa;
if (kode=='G')
{
strcpy(pesan,"GARUDA");
hargasewa=300000;
}
else if (kode=='E')
{
strcpy(pesan,"ELANG");
hargasewa=250000;
}
else if (kode=='C')
{
strcpy(pesan,"CENDRAWASIH");
hargasewa=90000;
}
else
{
strcpy(pesan,"salah Kode");
hargasewa=0;
}
cout<<endl;
cout<<endl;
cout<<"====================================="<<endl;
cout<<"BUKTI PEMESANAN KAMAR"<<endl;
cout<<"PENGINAPAN ABIE BAROKAH,Inn"<<endl;
cout<<"====================="<<endl;
cout<<"Nama Petugas :"<<nape<<endl;
cout<<"Nama Customer :"<<nacus<<endl;
cout<<"Tanggal Check In :"<<tgl<<endl;
cout<<"======================================"<<endl;
cout<<"Nama Kamar Yg Dipesan :"<<pesan<<endl;
cout<<"Harga Sewa :"<<hargasewa<<endl;
cout<<"Lama Sewa :"<<lamasewa<<endl;
cout<<"------------------------------------"<<endl;
jumbar=hargasewa*lamasewa;
cout<<"Jumlah Bayar :"<<jumbar<<endl;
if (lamasewa=3)
diskon=(jumbar/100)*5;
else if (lamasewa=4)
diskon=(jumbar/100)*5;
else if (lamasewa>=5)
diskon=(jumbar/100)*10;
else
diskon=(jumbar*0);
cout<<"Diskon :"<<diskon<<endl;
cout<<"-----------------------------"<<endl;
total=jumbar-diskon;
cout<<"Total Bayar :"<<total<<endl;
cout<<"Uang Bayar :";cin>>ubay;
ukem=ubay-total;
cout<<"Uang Kembalian :"<<ukem<<endl;
cout<<"----------------------------------------------"<<endl;
getch();
}
4. Runing programnya, dan alhasil menyerupai dibawah ini ;
Keterangan [PENTING] :
- Input nama petugasnya yang menginput data (ketik nama tanpa spasi, contohnya Hendri dan bukan
Hendri S/hendri Setiawan) - INput nama customer (ketik nama tanpa spasi, contohnya Hendri dan bukan
Hendri S/hendri Setiawan) - Input Tanggal dengan format 311299
- Pilih isyarat kamar huru kapital
- input usang sewa berapa hari
5. Maka alhasil menyerupai dibawah ini ;
6. SelesaiSumber http://www.hendrisetiawan.com