Kamis, 02 Mei 2013
Contoh Program C++ Reservasi Hotel
#include<stdio.h>
#include<conio.h>
#include<iostream.h>
#include<iomanip.h>
class penginapan
{
public:
char kode[5],*nama[5];
int harga[5],lama[5];
long int bayar[5];
};
main()
{
char lagi;
float total;
int i,j;
penginapan hotel;
awal:
clrscr();
cout<<"========================================="<<endl;
cout<<"*****WELCOME TO THE HOTEL CALIFORNIA*****"<<endl;
cout<<"-----------------------------------------"<<endl<<endl;
cout<<" -+-+-+- Daftar Harga Kamar Hotel -+-+-+-"<<endl;
cout<<" A : Kamar Eksekutif = Rp.300.000/night"<<endl;
cout<<" B : Kamar VIP\t = Rp.500.000/night"<<endl;
cout<<" C : Kamar VVIP\t = Rp.800.000/night"<<endl;
cout<<"========================================="<<endl<<endl<<endl;
cout<<"----------------------------------------"<<endl;
cout<<"****RESERVASI KAMAR HOTEL CALIFORNIA****"<<endl;
cout<<"========================================"<<endl
;
cout<<"Masukan Jumlah Data\t : ";cin>>j;
for (i=1;i<=j;i++)
{
cout<<"Data Penyewa ke-\t : "<<i<<endl;
cout<<"Masukan Kode Kamar [A/B/C] : ";cin>>hotel.kode[i];
if (hotel.kode[i]=='A'||hotel.kode[i]=='a')
{hotel.nama[i]="Kamar Eksekutif";
hotel.harga[i]=300000;
}
else if (hotel.kode[i]=='B'||hotel.kode[i]=='b')
{hotel.nama[i]="Kamar VIP";
hotel.harga[i]=500000;
}
else
{hotel.nama[i]="Kamar VVIP";
hotel.harga[i]=800000;
}
cout<<"Nama Kamar\t\t : "<<hotel.nama[i]<<endl;
cout<<"Harga Kamar\t\t : "<<hotel.harga[i]<<endl;
cout<<"Lama Sewa Kamar\t\t : ";cin>>hotel.lama[i];
hotel.bayar[i]=hotel.lama[i]*hotel.harga[i];
cout<<"Total Bayar\t\t : "<<hotel.bayar[i]<<endl;
cout<<endl;
}
cout<<endl<<endl;
clrscr();
cout<<"\t *****WELCOME TO THE HOTEL CALIFORNIA*****"<<endl;
cout<<"=================================================================="<<endl
;
cout<<"No. Kode Nama Harga Lama Biaya "<<endl;
cout<<" Kamar Kamar Sewa Sewa"<<endl;
cout<<"=================================================================="<<endl
;
for (i=1;i<=j;i++)
{
cout<<setiosflags(ios::left)<<setw(5)<<i;
cout<<setiosflags(ios::left)<<setw(10)<<hotel.kode[i];
cout<<setiosflags(ios::left)<<setw(10)<<hotel.nama[i];
cout<<setiosflags(ios::right)<<setprecision(8)<<setw(12)<<hotel.harga[i];
cout<<setiosflags(ios::right)<<setprecision(2)<<setw(10)<<hotel.lama[i];
cout<<setiosflags(ios::right)<<setprecision(8)<<setw(10)<<hotel.bayar[i]<<endl;
total=total+hotel.bayar[i];
}
cout<<"=================================================================="<<endl
;
cout<<"\n\t\t\t\t\tTotal Biaya = Rp."<<setprecision(10)<<total<<endl<<endl;
cout<<"Mau Isi Data Lagi?[Y/T]";cin>>lagi;
if(lagi=='Y'||lagi=='y')
goto awal;
else
goto akhir;
akhir:
getch();
}
Langganan:
Posting Komentar (Atom)
min itu pake borland apa codeblock
BalasHapus