Quick actions

cmd+k|ctrl+k

Navigation

Languages

AL 12.1

Snippet info

Language

Cpp

Visibility

public

Author

laodeiyan21

Created

2025-12-27T05:14:41.594342Z

Updated

2025-12-28T13:39:57.096578Z

#include <iostream>
#include <iomanip>
using namespace std;

struct Penginapan {
    string nama;
    char kode;
    int lama;
    string tipe;
    double harga;
    string souvenir;
    double admin;
    double total;
};

void Garis() {
    cout << "--------------------------------------------\n";
}

void Judul() {
    Garis();
    cout << "PENGINAPAN NUSANTARA INDAH\n";
    Garis();
}

void Ketentuan() {
    cout << "List Function\n";
    Garis();
    cout << "1. Function Garis()\n";
    cout << "2. Function Judul()\n";
    cout << "3. Function Ketentuan()\n";
    cout << "4. Function TTD()\n";
    cout << "5. Function infoTarif()\n";
    cout << "6. Function Cek_Tipe()\n";
    cout << "7. Function Cek_Harga()\n";
    cout << "8. Function Cek_Souvenir()\n";
    Garis();
    cout << "Harus bisa handle huruf besar dan kecil.\n";
    cout << "Harus menggunakan Struct.\n";
    Garis();
    cout << "Jika lama menginap lebih dari 6 hari maka mendapatkan gratis antar jemput\n";
    cout << "Biaya admin 200.000\n";
    cout << "Total Bayar adalah (Harga dikali Lama Menginap) + Biaya Admin\n";
    Garis();
}

void infoTarif() {
    cout << "| Kode | Tipe         | Harga   |\n";
    Garis();
    cout << "| A    | Standard     | 800.000 |\n";
    cout << "| B    | Deluxe       | 700.000 |\n";
    cout << "| C    | Suite        | 600.000 |\n";
    Garis();
}

void ttd(Penginapan &p) {
    cin >> p.nama >> p.kode >> p.lama;
}

void Cek_Tipe(Penginapan &p) {
    if      (p.kode == 'A' || p.kode == 'a') p.tipe = "Standard";
    else if (p.kode == 'B' || p.kode == 'b') p.tipe = "Deluxe";
    else if (p.kode == 'C' || p.kode == 'c') p.tipe = "Suite";
}

void Cek_Harga(Penginapan &p) {
        if  (p.kode == 'A' || p.kode == 'a') p.harga = 800000;
    else if (p.kode == 'B' || p.kode == 'b') p.harga = 700000;
    else if (p.kode == 'C' || p.kode == 'c') p.harga = 600000;
}

void Cek_Souvenir(Penginapan &p) {
    if (p.lama > 6) p.souvenir = "gratis antar jemput";
    else p.souvenir = "-";
}

int main() {
    Penginapan p;
    p.admin = 200000;

    Judul();
    Ketentuan();
    infoTarif();

    ttd(p);
    Cek_Tipe(p);
    Cek_Harga(p);
    Cek_Souvenir(p);

    p.total = (p.harga * p.lama) + p.admin;

    cout << fixed << setprecision(2);
    cout << "Nama Penyewa      : " << p.nama << endl;
    cout << "Kode Kamar [A/B/C]: " << p.kode << endl;
    cout << "Lama Menginap     : " << p.lama << " hari\n";
    cout << "Harga Sewa        : Rp." << p.harga << endl;
    cout << "Tipe Kamar        : " << p.tipe << endl;
    cout << "Souvenir          : " << p.souvenir << endl;
    cout << "Administrasi      : Rp." << p.admin << endl;
    cout << "Total Biaya       : Rp." << p.total << endl;
    Garis();
    cout << "Nama  : la ode ian\n";
    cout << "Email : laodeian21.com\n";

    return 0;
}
INFO