ASSIGNMENT II
 

(Loops, Loops and More Loops)

Requirements and Assumptions:
Recall that in Assignment I, you  read passenger information and showed the passenger a copy of the ticket and the cost.  See Assignment I for details. In this assignment, you will enhance the code in Assignment I in the following ways.

In addition to printing the information on the ticket add a Confirmation Number, which should be a random number of exactly 5 digits.

The information read from the passenger  in Assignment I included the following:

Name:
Address:
Telephone Number:
Preferred Time of Flight (6AM/12N/ 4PM/10PM):
Preferred Seat  (Aisle/Window/None):
Number of Bags to Check In:

Now,  instead just reading  input  from one passenger and printing the information, your program must keep looping
until the user decides to quit. Therefore you must include the following choices in the first screen

Pick from the following menu:

1 -- Request Reservation
2 -- Quit Program

If the  user  chose 1, then continue to process the passenger information as you did in Assignment I, (but now there is also a confimation number to print) and, when done,  display the above menu again. Keep repeating the processing and display of the above choices until the user chooses to quit.

You will include checks of validity of the input. The name and address and telephone number could be any string. The "Preferred Time of  Flight" must be now be one of 6, 4, 10 or 12. Similary, the "Preferred Seat" must be read as a character an be one of  'A', 'W' or 'N'.  The number of bags must be between 0 to 5. You must keep looping until the correct format is entered for each of the inputs.  Ensure you provide to the user the correct format for entering information. This is especially true, if an invalid input is entered.

Note that there are 32 rows in each of the flight.  Assume that there will not be more than 64 passengers requesting reservation per flight. Therefore, the first person gets a seat in Row  1,  second  person  gets a seat in Row 2 etc .  on  each flight.  Once 32 rows are filled in, restart at Row 1 again. For the first 32 passengers use A if they desire a Window seat and use C if they desire an Aisle seat and B if they choose no particular preference. During the second round of 32 passengers, use F if they desire a Window seat and D if they desire an Aisle seat and E if desire no preference.   Since there are only 64 passengers per  flight, this scheme is guaranteed not to cause any conflict (why?).
 

When a flight gets full indicate that the flight is full. It is possible that one flight is full (for example, the 6AM) and others are not. You need to keep four counters to keep track the count of people booked on each flight. If a flight is full the program should print the main menu again so that they can pick another flight.
 

The cost of the ticket is computed exactly like in Assignment I.  The  basic cost of ticket is as follows:
                 6AM flight ----  $50
                 12Noon      ----   $ 70
                 4PM            ----- $60
                 10PM         ------ $55
The is an airport tax of $3. There is no cost to carry two bags. However, for every additional bag,
the cost is  $15.45 per bag. This time the maximum bags allowed is 5.

After computing the price  of the ticket,  and generating the seat number, print the following information:

Here is a copy of your ticket:

Name of Passenger:                                             Address:                                     Telephone Number:
Time of Flight:                                                     Seat Number:                             Number of Bags:

Here are some numbers you may need to refer to your reservation.

Confirmation Number:
 
 
 


Example Session:  The items in italics are printed by the program and items in bold are the user input.
 

Welcome to my program!!  (John Smith, Assignment II)

Pick from the following menu:

1 -- Request Reservation
2 -- Quit Program

Your Choice: 1

Welcome to Kettering International Airlines, please provide the following information to book a flight.

Name:  Saroja Kanchi
Address:  3456 Hollywood Blvd, Los Angeles, CA 90003
Telephone Number: (123)-456-7890
Preferred Time of Flight(6AM/12Noon/ 4PM/10PM): 4
Preferred Seat  (Aisle/Window/None): Q

******* INVALID INPUT:  Q is not a valid  input, Please input one of I, W or N

Preferred Seat  (Aisle/Window/None): W
Number of Bags to Check In: 4

Here is a copy of your ticket:

Name of Passenger:Saroja Kanchi              Address:  3456 Hollywood Blvd, Los Angeles, CA 90003          Telephone Number: 123-456-7890
Time of Flight:   4PM                                    Seat Number:  1A                                       Number of Bags: 4

Cost of your ticket is  $93.90
Here are some numbers you may need to refer to your reservation.

Confirmation Number: 95340

 Hope you have a nice flight, ( if we can find a pilot that is, .....), Bye

Pick from the following menu:

1 -- Enter Passenger Information
2 -- Quit Program

Your Choice: 1

Welcome to Kettering International Airlines, please provide the following information to book a flight.

Name:  John  Doe
Address:  3456 Hollywood Blvd, Los Angeles, CA 90003
Telephone Number: 111-444-0000
Preferred Time of Flight(6AM/12Noon/ 4PM/10PM): 6
Preferred Seat  (Aisle/Window/None): W
Number of Bags to Check In: 10

**** Invalid : Please ensure the bags are between 0 an 5.

Number of Bags to Check In: 3

Here is a copy of your ticket:

Name of Passenger:Jane Doe              Address:  3456 Hollywood Blvd, Los Angeles, CA 90003          Telephone Number: 111-444-00000

Time of Flight:   6PM                                    Seat Number:  1A                                       Number of Bags: 3

Cost of your Tickcet is  $68.45

Here are some numbers you may need to refer to your reservation.

Confirmation Number: 77343

 Hope you have a nice flight, ( if we can find a pilot that is, .....), Bye

Pick from the following menu:

1 -- Enter Passenger Information
2 -- Quit Program
 

(* And the program continues from here  until the user chooses 2 *)


Internal Requirements:
1. Use as many constants as needed. Constants are declared using the keyword 'final'.  There must be constant
for LOWER_BAG_COUNT (set to 0) , UPPER_BAG_COUNT (set to 5), and NUMBER_OF_ROWS.
 

2. You cannot use arrays in this assignment. You have to use loops and still be able to assign the correct
symbol (A,B,C,D or E) for the seat.

3.  Use loops of checking validity of each input.
 


                           FOLLOW ALL STYLE GUIDE LINES AND SUBMISSION INSTRUCTIONS.     Assignments and Labs Page CPSC101 Homepage Saroja Kanchi's Homepage