Studi Kasus
Membuat program untuk menghitung biaya menginap di hotel dengan ketentuan. Gunakan percabangan, perulangan, array, struct, prosedur dan fungsi.
- Jenis kamar yang tersedia antara lain :
- VVIP ⇛ 1 juta/malam
- VIP ⇛ 500 ribu/malam
- Switt ⇛ 250 Ribu/malam
- Fasilitas Tambahan
- Extra Bed Besar ⇛ 75 ribu/malam
- Extra Bed Kecil ⇛ 50 ribu/malam
- Laundry Expres ⇛ 20 ribu/malam
- Dry Cleaning ⇛ 30 ribu/malam
- Lunch ⇛ 50 ribu/malam
Apabila iya, maka muncul menu fasilitas tambahan. Kemudian akan diminta menginputkan beberapa jenis fasilitas tambahan, Jenis Fasilitas dan jumlahnya. Program akan menampilkan data diri, total biaya kamar, total biaya fasilitas tambahan dan total yang harus dibayar.
Source code
#include <iostream>
#include <stdlib.h>
#define VVIP 1000000
#define VIP 500000
#define Switt 250000
#define Extra_Bed_Besar 75000
#define Extra_Bed_Kecil 50000
#define Laundry_Express 20000
#define Dry_Cleaning 30000
#define Lunch 50000
using namespace std;
struct dataVariabel{
string nama,alamat,Nhp,inputFal;
int plhKamar,FalTambah,inputEBB,inputEBK,inputLE,inputDC,inputL;
double JmlFal,HrgFal,totFal;
};
dataVariabel dtV;
struct dataUlang{
string NamaFal[10];
int JumlahFal[10];
double HargaFal[10];
};
dataUlang dtU;
void InputIdentitas(){
cout<<" Nama : ";getline(cin,(dtV.nama));
cout<<" Alamat : ";cin>>dtV.alamat;
cout<<" Nomer Hp : ";cin>>dtV.Nhp;
}
void FasilitasTambah(){
cout<<"Apakah mau Menambah Fasilitas ? <y/t> ";cin>>dtV.inputFal;cout<<endl;
if(dtV.inputFal=="y")
{
cout<<"-----------------------------------------"<<endl;
cout<<"| Daftar Fasilitas Tambahan |"<<endl;
cout<<"-----------------------------------------"<<endl;
cout<<"| 1.Extra Bed Besar /malam : ";cin>>dtV.inputEBB;
cout<<"| 2.Extra Bed Kecil /malam : ";cin>>dtV.inputEBK;
cout<<"| 3.Laundry Expres /malam : ";cin>>dtV.inputLE;
cout<<"| 4.Dry Cleaning /malam : ";cin>>dtV.inputDC;
cout<<"| 5.Lunch /Jumlah : ";cin>>dtV.inputL;
cout<<"-----------------------------------------"<<endl;
dtV.totFal=((Extra_Bed_Besar*dtV.inputEBB)+(Extra_Bed_Kecil*dtV.inputEBK)+(Laundry_Express*dtV.inputLE)+(Dry_Cleaning*dtV.inputDC)+(Lunch*dtV.inputL));
}else if(dtV.inputFal=="t"){
cout<<"-----------------------------------------"<<endl;
cout<<"| ANDA TIDAK MENAMBAH APAPUN |"<<endl;
cout<<"-----------------------------------------"<<endl;
}else{
cout<<"-----------------------------------------"<<endl;
cout<<"| MAAF, Data yang Anda input SALAH !!! |"<<endl;
cout<<"-----------------------------------------"<<endl;
}
}
void AngkaLamaMenginap(){
cout<<"Lama Menginap perMalam? ";cin>>dtV.plhKamar;
}
double LamaMenginapVVIP(int a){
double hasil;
hasil=dtV.plhKamar*VVIP;
return hasil;
}
double LamaMenginapVIP(int a){
double hasil;
hasil=dtV.plhKamar*VIP;
return hasil;
}
double LamaMenginapSwitt(int a){
double hasil;
hasil=dtV.plhKamar*Switt;
return hasil;
}
void JenisKamarDanLama(){
cout<<"Jenis Kamar yang tersedia : "<<endl;
cout<<" 1. VVIP Rp.1.000.000/malam"<<endl;
cout<<" 2. VIP Rp.500.000/malam"<<endl;
cout<<" 3. Switt Rp.250.000/malam"<<endl;
cout<<"Silahkan Memilih kamar <1,2,3> ? ";cin>>dtV.plhKamar;
switch(dtV.plhKamar)
{
case 1:
{
cout<<"-----------------------------------------"<<endl;
cout<<"| >> 1. VVIP (ROOM) << |"<<endl;
cout<<"-----------------------------------------"<<endl;
AngkaLamaMenginap();
FasilitasTambah();
double TotalBiayaKmr,TotKel;
TotKel=LamaMenginapVVIP(dtV.plhKamar)+dtV.totFal;
system("cls");
cout<<"-----------------------------------------"<<endl;
cout<<"| Nama : "<<dtV.nama<<endl;
cout<<"| Alamat : "<<dtV.alamat<<endl;
cout<<"| Nomer Hp : "<<dtV.Nhp<<endl;
cout<<"-----------------------------------------"<<endl;
cout<<"| Lama Menginap : "<<dtV.plhKamar<<" Malam"<<endl;
cout<<"| Total Biaya Kamar : Rp."<<LamaMenginapVVIP(dtV.plhKamar)<<endl;
cout<<"| Total Biaya Fasilitas : Rp."<<dtV.totFal<<endl;
cout<<"| Total Biaya keseluruhan : Rp."<<TotKel<<endl;
cout<<"-----------------------------------------"<<endl;
};break;
case 2:{
cout<<"-----------------------------------------"<<endl;
cout<<"| >> 2. VIP (ROOM) << |"<<endl;
cout<<"-----------------------------------------"<<endl;
AngkaLamaMenginap();
FasilitasTambah();
double TotalBiayaKmr,TotKel;
TotKel=LamaMenginapVIP(dtV.plhKamar)+dtV.totFal;
system("cls");
cout<<"-----------------------------------------"<<endl;
cout<<"| Nama : "<<dtV.nama<<endl;
cout<<"| Alamat : "<<dtV.alamat<<endl;
cout<<"| Nomer Hp : "<<dtV.Nhp<<endl;
cout<<"-----------------------------------------"<<endl;
cout<<" Lama Menginap : "<<dtV.plhKamar<<" Malam"<<endl;
cout<<" Total Biaya Kamar : Rp."<<LamaMenginapVIP(dtV.plhKamar)<<endl;
cout<<" Total Biaya Fasilitas : Rp."<<dtV.totFal<<endl;
cout<<" Total Biaya keseluruhan : Rp."<<TotKel<<endl;
cout<<"-----------------------------------------"<<endl;
};break;
case 3:{
cout<<"-----------------------------------------"<<endl;
cout<<"| >> 3. Switt (ROOM) << |"<<endl;
cout<<"-----------------------------------------"<<endl;
AngkaLamaMenginap();
FasilitasTambah();
double TotalBiayaKmr,TotKel;
TotKel=LamaMenginapSwitt(dtV.plhKamar)+dtV.totFal;
system("cls");
cout<<"-----------------------------------------"<<endl;
cout<<" Nama : "<<dtV.nama<<endl;
cout<<" Alamat : "<<dtV.alamat<<endl;
cout<<" Nomer Hp : "<<dtV.Nhp<<endl;
cout<<"-----------------------------------------"<<endl;
cout<<" Lama Menginap : "<<dtV.plhKamar<<" Malam"<<endl;
cout<<" Total Biaya Kamar : Rp."<<LamaMenginapSwitt(dtV.plhKamar)<<endl;
cout<<" Total Biaya Fasilitas : Rp."<<dtV.totFal<<endl;
cout<<" Total Biaya keseluruhan : Rp."<<TotKel<<endl;
cout<<"-----------------------------------------"<<endl;
};break;
default :{
cout<<"========================================="<<endl;
cout<<"| **MAAF !!! NILAI DILUAR JANGKAUAN** |"<<endl;
cout<<"========================================="<<endl;
}
}
}
main(){
string inpt_psn;
do{
cout<<"========================================="<<endl;
cout<<"| |"<<endl;
cout<<"| PENGINAPAN HOTEL BOLAWEN |"<<endl;
cout<<"| |"<<endl;
cout<<"========================================="<<endl;
InputIdentitas();
JenisKamarDanLama();
cout<<"Mau Memesan Lagi ? <y/t> : ";cin>>inpt_psn;
}while (inpt_psn =="y");
}