#include <iostream>
#include <stdio.h>
#include <string.h>
#include <cctype>
using namespace std;
struct Penyewa {
char nama[30];
char kode;
int lama;
char tipe[20];
long long harga;
long long admin;
char souvenir[30];
};
void Garis();
void Judul();
void Ketentuan();
void TTD();
void infoTarif();
void Cek_Tipe(Penyewa *p);
void Cek_Harga(Penyewa *p);
void Cek_Souvenir(Penyewa *p);
void Garis() {
puts("==================================================================");
}
void Judul() {
Garis();
puts("PENGINAPAN WISTERIA");
Garis();
}
void Ketentuan() {
puts("List Function");
Garis();
puts("1. Function Garis()");
puts("2. Function Judul()");
puts("3. Function Ketentuan()");
puts("4. Function TTD()");
puts("5. Function infoTarif()");
puts("6. Function Cek_Tipe()");
puts("7. Function Cek_Harga()");
puts("8. Function Cek_Souvenir()");
Garis();
puts("Harus bisa handle huruf besar dan kecil.");
puts("Harus menggunakan Struct.");
Garis();
puts("Jika lama menginap lebih dari 6 hari maka mendapatkan souvenir Keychain");
puts("Biaya admin = Rp 200.000");
puts("Total bayar adalah (Harga dikali Lama Menginap) + Biaya Admin");
Garis();
}
void infoTarif() {
puts("| Kode | Tipe | Harga |");
Garis();
puts("| A | Blue | Rp 800.000 |");
puts("| B | Yellow | Rp 700.000 |");
puts("| C | Red | Rp 600.000 |");
Garis();
}
void Cek_Tipe(Penyewa *p) {
switch (toupper(p->kode)) {
case 'A': strcpy(p->tipe, "Anggrek"); break;
case 'B': strcpy(p->tipe, "Bougenville"); break;
case 'C': strcpy(p->tipe, "Mawar"); break;
default : strcpy(p->tipe, "Tidak Valid");
}
}
void Cek_Harga(Penyewa *p) {
switch (toupper(p->kode)) {
case 'A': p->harga = 800000; break;
case 'B': p->harga = 700000; break;
case 'C': p->harga = 600000; break;
default : p->harga = 0;
}
p->admin = 200000;
}
void Cek_Souvenir(Penyewa *p) {
if (p->lama > 6)
strcpy(p->souvenir, "Keychain");
else
strcpy(p->souvenir, "-");
}
void TTD() {
Garis();
puts("Nama : Ananda Rakhma Aulia");
puts("Email : anandara7891@gmail.com");
puts("NIM : 3420220024");
}
int main() {
Penyewa p;
Judul();
Ketentuan();
puts("Nama Penyewa :");
puts("Kode Kamar :");
puts("Lama Menginap :");
cin >> p.nama >> p.kode >> p.lama;
Garis();
infoTarif();
Cek_Tipe(&p);
Cek_Harga(&p);
Cek_Souvenir(&p);
long long total = (p.harga * p.lama) + p.admin;
cout << "HASIL PERHITUNGAN\n";
Garis();
cout << "Nama Penyewa : " << p.nama << endl;
cout << "Kode Kamar : " << p.kode << endl;
cout << "Lama Menginap: " << p.lama << " Hari" << endl;
cout << "Harga Sewa : Rp " << p.harga << ".00" << endl;
cout << "Tipe Kamar : " << p.tipe << endl;
cout << "Souvenir : " << p.souvenir << endl;
cout << "Administrasi : Rp " << p.admin << ".00" << endl;
cout << "Total Biaya : Rp " << total << ".00" << endl;
TTD();
return 0;
}