At the end of the program, the program will determine if the reservation for flights and/or hotel is booked. The program should have the following logic:

Objectives

The goal of this assignment is to learn the following:

  • More practice with conditionals
  • More practice with lexical scoping
  • How to analyze problem statements in plain English

Computer Science Principles Curriculum

  • Big Idea: Programming: EK 5.1.2B, EK 5.1.2E, EK 5.2.1F, EK 5.1.2J, EK 5.2.1C, EK 5.3.1D, EK 5.3.1I, EK 5.4.1

Common Core Standards

  • English Language Arts Standards » Science & Technical Subjects: CCSS.ELA-Literacy.RST.9-10.2, CCSS.ELA-Literacy.RST.9-10.3, CCSS.ELA-Literacy.RST.9-10.4, CCSS.ELA-Literacy.RST.9-10.5, CCSS.ELA-Literacy.RST.9-10.6, CCSS.ELA-Literacy.RST.11-12.2, CCSS.ELA-Literacy.RST.11-12.3
  • Standards For Mathmatical Practice: CCSS.Math.Practice.MP1, CCSS.Math.Practice.MP2, CCSS.Math.Practice.MP5, CCSS.Math.Practice.MP6, CCSS.Math.Practice.MP7, CCSS.Math.Practice.MP8

Overview

Write a small travel reservation program for a travel agency to book vacation packages for clients. The program will ask the user to pick one of the offered destinations for flights and have an option of booking a hotel room. At the end of the reservation process the program will provide the user with all of the booking information. Create a new project and name it Travel.

Description

A small travel agency in St. Louis offers vacation packages to clients in the St. Louis area. Since the travel agency is small, it offers only a small number of destinations and hotels at the selected destination. Write a program to help the travel agency make flight and hotel reservations for their clients.

The travel agency wants to know the number of travelers planning to go on the trip. Prompt the client for the number of people who will be traveling. The program should only accept the input value of one or more travelers. There is no limit for the number of travelers. If the client enters a value of zero or less, the program should reset the value to one traveler and inform the client of an error.

After the user has entered the number of travelers the program should provide a list of offered destinations with a price (per person) for each destination for the client to book a round trip flight. Prompt the client to select a destination number by entering an integer value. The program will determine which destination to get and store the correct city name and price. A list of cities with prices is shown in the table below:


Destination / Round Trip Fare
DestinationRound Trip Fare
Chicago$200.00
Los Angeles$360.00
Miami$320.00
Orlando$310.00
Seattle$330.00

The program should also test if the client entered the correct value for the destination. If the client enters a value that is not within the range of offered destinations, the program will assume that the client does not want any of the listed destinations.

After obtaining the client’s flight reservation request, the program will calculate a total price of the flight itinerary with the round trip fare and a number of travelers.

If the flight reservation has been made successfully, the program will offer the client an option of booking a hotel room. If the flights were not booked, the hotel option should be skipped. The client will be asked to book a hotel room or opt out of the hotel option. The program should ask the client the question, "Would you like to include hotel in your package (Y/N)?" Both upper and lower cases (Y, y, N, n) are acceptable. If the client chooses to include hotel in the package, the program will proceed and ask the client a couple of questions. If the client does not want to include hotel in the package, the hotel option is not included. If an incorrect value is entered, no hotel reservation will also be made.

When the client wants to include hotel in the package, the program will do the following:

  • Ask the client to select one of the three following hotel types with a price for each to get and store the hotel type and price:

Hotel Type / Price
Hotel TypePrice
Motel$49.99
Standard Hotel$98.50
Luxury Hotel$199.75
  • If the client does not enter a correct integer value for any of three hotel types, the program will automatically reset the hotel type to Standard Hotel and price to $98.50.

  • Ask the client to enter a number of hotel rooms. If the input is zero or less, then the number of hotel rooms will be reset to one.
  • Ask the client to enter a number of nights to stay at the hotel. If the input is zero or less, then the number of nights will be reset to one.
  • Calculate the total hotel price with the hotel price, a number of rooms, and a number of nights.
  • If both flights and hotel have been booked, the program will calculate the total price of flights and hotel and output the package details with flights and hotel information and the total price.
  • If the flights were only booked and the hotel option was not chosen, the program will output the flight itinerary details with information and price.
  • If the flights were not booked, then the program will announce that no reservation has been made.

Sample Output

The input dialog statements are included in the sample output. They are identified as [Input Dialog].

Flights and Hotel Reservation

Welcome to the travel agency. You offer travel packages for your vacation destinations.
[Input Dialog] How many people will be traveling? 4
Select one of the destinations to book a flight: 1 - Chicago ($200), 2 - Los Angeles ($360), 3 - Miami ($320), 4 - Orlando ($310), 5 - Seattle ($330)
[Input Dialog] Enter the destination number: 3
[Input Dialog] Would you like to include hotel in your package (Y/N)? Y
What kind of hotel would you like to book? 1 - Motel ($49.99), 2 - Standard Hotel ($98.50), 3 - Luxury Hotel ($199.75)
[Input Dialog] Enter the hotel number: 2
[Input Dialog] Enter a number of hotel rooms: 1
[Input Dialog] Enter a number of nights to stay at the hotel: 3
The reservation for flights and hotel has been booked.
Total flight price to Miami for 4 traveler(s) is $1280.0
Total hotel price for 1 room(s) at Standard Hotel for 3 night(s) is $295.5
Total package price for flights and hotel is $1575.5

Flights Reservation Only

Welcome to the travel agency. You offer travel packages for your vacation destinations.
[Input Dialog] How many people will be traveling? 3
Select one of the destinations to book a flight: 1 - Chicago ($200), 2 - Los Angeles ($360), 3 - Miami ($320), 4 - Orlando ($310), 5 - Seattle ($330)
[Input Dialog] Enter the destination number: 5
[Input Dialog] Would you like to include hotel in your package (Y/N)? n
The reservation for flights has been booked.
Total flight price to Seattle for 3 traveler(s) is $990.0

No Reservation

Welcome to the travel agency. You offer travel packages for your vacation destinations.
[Input Dialog] How many people will be traveling? 1
Select one of the destinations to book a flight: 1 - Chicago ($200), 2 - Los Angeles ($360), 3 - Miami ($320), 4 - Orlando ($310), 5 - Seattle ($330)
[Input Dialog] Enter the destination number: 6
No reservation has been made. Please come back again!

Reservation With Errors and Automatic Resets

Welcome to the travel agency. You offer travel packages for your vacation destinations.
[Input Dialog] How many people will be traveling? 0
Error: The number of travelers has been reset to 1. You entered 0
Select one of the destinations to book a flight: 1 - Chicago ($200), 2 - Los Angeles ($360), 3 - Miami ($320), 4 - Orlando ($310), 5 - Seattle ($330)
[Input Dialog] Enter the destination number: 1
[Input Dialog] Would you like to include hotel in your package (Y/N)? Y
What kind of hotel would you like to book? 1 - Motel ($49.99), 2 - Standard Hotel ($98.50), 3 - Luxury Hotel ($199.75)
[Input Dialog] Enter the hotel number: 4
Error: The hotel type has been assigned to (2) Standard Hotel. You entered 4
[Input Dialog] Enter a number of hotel rooms: 0
Error: The number of hotel room has been reset to 1. You entered 0
[Input Dialog] Enter a number of nights to stay at the hotel: -1
Error: The number of nights has been reset to 1. You entered -1
The reservation for flights and hotel has been booked.
Total flight price to Chicago for 1 traveler(s) is $200.0
Total hotel price for 1 room(s) at Standard Hotel for 1 night(s) is $98.5
Total package price for flights and hotel is $298.5

Next Tutorial

In the next tutorial, we will discuss Assignment 3.2, which describes how work Number Guessing Game in Quorum..