ASSIGNMENT I

(covers Console I/O, assignment, limited branching statement)


 


Requirements and Assumptions:

In this assignment, you will read information for booking a flight for a passenger using an airline.   The airline operates only between Flint and Toronto (it is an International Flight !!). Once the information from the passenger is read, you will then provide a cost of the ticket to the  passenger and  print a copy of the ticket.

The information read from the passenger includes the following: Read the "Name", "Address" and "Telephone number as a string and "Preferred Time of Flight" as an integer (6,12,4 or 10) and "Preferred Seat"as a character ('A', 'W', or 'N') and Number of Bags as an integer.

Name:
Address:
Telephone Number:
Preferred Time of Flight ([6]AM/[12]Noon/ [4]PM/[10]PM):
Preferred Seat  ([A]isle/[W]indow/[N]one):
Number of Bags to Check In:

For this assignment make the following assumptions:

1. There is only passenger who requests a ticket at a time, so he or she always gets all  preferences met.
2.  There are four times for departure from Flint: 6AM, 12Noon, 4PM and 10PM.
3.   The seating preference can be Aisle, Window or None.  Again , the passenger gets  the desired preference.
4. The  basic cost of ticket is as follows:
                 6AM flight ----  $50
                 12Noon      ----   $ 70
                 4PM            ----- $60
                 10PM         ------ $55
5. The is an airport tax of $3.

6.  The number of bags allowed per passenger is two. There is no cost to carry two bags. However, for every additional bag, the cost is  $15.45 per bag. No passenger is allowed more than 5 bags.

7. Assume that the passenger will be seated in Row #1.

8. Assign seat "1A" if Window seat is desired and "1B" if no preference is given and "1C" if Aisle seat is desired.

Once the preferences are read, calculate the total cost as the sum of  basic cost, additional bag cost and the airport tax.

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

Name of Passenger:                                   Address:                                     Telephone Number:
Time of Flight:                                            Seat Number:                              Number of Bags:
Your Ticket Cost:

Have a Wonderful Flight! We have beverages and cocktails to keep you busy...


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

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 ([6]AM/[12]Noon/ [4]PM/[10]PM): 4
Preferred Seat  ([A]isle/[W]indow/[N]one):W
Number of Bags to Check In: 4


Hello, Saroja Kanchi, here is the cost and 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.

Have a Wonderful Flight! We have beverages and cocktails to keep you busy...
 
 


Internal Requirements:
1.  Note that in the above session, "Preferred Time of Flight" is read  as just 4 rather than 4PM. This is to facilitate reading of integers and using if or switch statement on the integer. If you read 4PM as a string, you will have to either parse the string, or use comparison of strings.

2.  The above note  holds for "Preferred Seat"  also.

3. Reading of strings can be done using "MyReadString" routine in the "ReadUtility".  Strings should be used for reading (and printing) name, address, telephone number etc.

4. I do not expect you do many error checks at this point. Assume that all inputs are valid.

5. The entire program is expected to be in the main() method.  A more ideal case would be to separate them into methods.

6. Note that when you print the cost of the ticket, you will see that Java prints more decimal places than just two. For example, $93.90 may be output is $93.899999999999 or $93.90000000000001.  You need not fix  that
problem in this assignment.


           FOLLOW ALL STYLE GUIDE LINES AND SUBMISSION INSTRUCTIONS.