Description
The purpose of this challenge is to use conditional constructs (IF-ELSE, IF-ELSE-IF, nested IF statements). This challenge simulates a hotel reservation system.
Requirements
- Ask the user to enter their first name. Don’t forget to first declare a variable for the first name.
- Ask the user to enter their last name. Don’t forget to first declare a variable for the last name.
- Ask the user to enter their age. Don’t forget to first declare a variable for the age.
- If the user is younger than 18 yrs old, display a message indicating that they cannot make a hotel reservation. Otherwise, continue and ask the user more questions (see below)
- Ask the user what kind of bed is preferred (king size, queen size, twin). You must use an if-else-if construct to display a friendly message about the selected bed type. (Hint: Use a char variable)
- Ask the user how many nights the reservation will include
- Ask the user what room type is preferred (beach view, city view, balcony, garden view. In this hotel, all room reservations typically cost $100/night. However, Beach View rooms cost $25 more. You can use any IF construct here (IF, IF-ELSE, IF-ELSE-IF, nested IFs).
- Additionally, rooms with king size beds cost $10 more. This cost is added to the room cost regardless of room type.
- Display a message indicating the cost of the reservation. A 5% city tax is also added to the cost.
DO NOT USE
You may not use any looping mechanisms or user-defined functions.
Sample Interaction / Output
RUN IT AGAIN:
In the sample interaction above, the final bill is calculated as $100 + $25 + $10 per room (surcharges for Beach View and King Size bed), for 2 nights, plus tax. Make sure you test your code with various combinations of rooms and beds.
Hints
- It’s good practice to initialize variables to default values that make sense
- Include the <iomanip> header file. This will allow you to use various options to format your output such as setprecision
- Include the code below before any other cout lines. The setprecision(x) will display your decimal output with x decimal places.
LEGEND
PROGRAM OUTPUT
USER ENTRY
FROM INPUT
CATALOG ID: CPP-FLOW0003b
Print Requirements