Airbnb

Pasted Sep 30, 2026, 5:50 PM1 file129 lines

Scan to open on your phone

Point a camera at the QR code - it opens this exact paste, no app needed.

https://codepastes.com/zzgt6yfqhs8jm527
Airbnb
#include <iostream>
#include <iomanip>
using namespace std;

int main() {

    // Variables to store the user's choices
    int destination, accommodation;
    int nights, guests;

    // Variables used for calculating the booking price
    double pricePerNight = 0;
    double totalPrice;

    // Display the welcome message
    cout << "========================================" << endl;
    cout << "       AIRBNB BOOKING SYSTEM" << endl;
    cout << "========================================" << endl;

    // Ask the user to choose where they want to stay
    cout << "\nChoose your destination:" << endl;
    cout << "1. Kuala Lumpur" << endl;
    cout << "2. Penang" << endl;
    cout << "3. Johor Bahru" << endl;
    cout << "Enter your choice: ";
    cin >> destination;

    // Store the destination name so it can be shown later
    string destinationName;

    // Check which destination the user selected
    switch (destination) {
        case 1:
            destinationName = "Kuala Lumpur";
            break;
        case 2:
            destinationName = "Penang";
            break;
        case 3:
            destinationName = "Johor Bahru";
            break;
        default:
            // Stop the program if the choice is not available
            cout << "Invalid destination choice." << endl;
            return 0;
    }

    // Ask the user to choose the type of accommodation
    cout << "\nChoose your accommodation:" << endl;
    cout << "1. Private Room - RM100 per night" << endl;
    cout << "2. Entire Apartment - RM180 per night" << endl;
    cout << "3. Villa - RM300 per night" << endl;
    cout << "Enter your choice: ";
    cin >> accommodation;

    // Store the selected accommodation name
    string accommodationName;

    // Set the accommodation name and its price per night
    switch (accommodation) {
        case 1:
            accommodationName = "Private Room";
            pricePerNight = 100;
            break;
        case 2:
            accommodationName = "Entire Apartment";
            pricePerNight = 180;
            break;
        case 3:
            accommodationName = "Villa";
            pricePerNight = 300;
            break;
        default:
            // Stop if the user enters an invalid accommodation choice
            cout << "Invalid accommodation choice." << endl;
            return 0;
    }

    // Ask how many nights the user wants to stay
    cout << "\nEnter number of nights: ";
    cin >> nights;

    // Make sure the number of nights is valid
    if (nights <= 0) {
        cout << "Number of nights must be at least 1." << endl;
        return 0;
    }

    // Ask how many guests will be staying
    cout << "Enter number of guests: ";
    cin >> guests;

    // Make sure there is at least one guest
    if (guests <= 0) {
        cout << "Number of guests must be at least 1." << endl;
        return 0;
    }

    // Calculate the basic total price
    totalPrice = pricePerNight * nights;

    // Add an extra RM50 if there are more than 4 guests
    if (guests > 4) {
        totalPrice = totalPrice + 50;
    }

    // Show the price with 2 decimal places
    cout << fixed << setprecision(2);

    // Display all the booking details
    cout << "\n========================================" << endl;
    cout << "          BOOKING SUMMARY" << endl;
    cout << "========================================" << endl;

    cout << "Destination      : " << destinationName << endl;
    cout << "Accommodation    : " << accommodationName << endl;
    cout << "Number of nights : " << nights << endl;
    cout << "Number of guests : " << guests << endl;
    cout << "Price per night  : RM" << pricePerNight << endl;
    cout << "Estimated total  : RM" << totalPrice << endl;

    // End of the booking summary
    cout << "========================================" << endl;
    cout << "Thank you for using our Airbnb Booking System!" << endl;
    cout << "========================================" << endl;

    return 0;
}

4,014 chars · codepastes.com