CP1401 Assignment 2 -  Implement the Tropical Airlines program

Question # 00749463 Posted By: dr.tony Updated on: 01/21/2020 09:33 AM Due on: 01/21/2020
Subject Education Topic General Education Tutorials:
Question
Dot Image

 CP1401 SP53 2019 Assignment 2

Implement the Tropical Airlines program 

Task

You are to implement (code in Python) a plane ticket ordering program as described in the following description. Use what you have learned in class, including simple functions, selection, repetition and lists. You should use any feedback that you received from Assignment 1 to improve your program flow.

 

 

See the last section of this document for sample output showing how the program should run.

 

Program Features:

 

Short description: The program will begin by asking the user for their name, welcoming them and then displaying a menu with three choices, as shown below. Choosing ‘Instructions’ or ‘Order’ will make the program perform the actions described below. If the user chooses to ‘Exit’ the program will display the costs of each order they have made using the program, and then a farewell message as described below. Any invalid value will produce an error message. After every menu selection (other than ‘Exit’) the menu will be displayed again.

 

The ‘Instructions’ option will display a short paragraph explaining the program, as shown below. The ‘Order’ option will take the user through a series of choices to order a single ticket. Once the choices are made the program will display a summary of the user’s choices and a final total for the ticket. After either of these options, the menu will be displayed again. When the user chooses (E)xit, a listing of the totals from the previous orders should be displayed with the output message “Your orders are:”, followed by the previous order totals in ascending order (smallest to largest) and a final total of all the orders combined. Then the message “Thank you for visiting Tropical Airlines” will be displayed.

 

See next page for Detailed Instructions.

 

 

 

Detailed instructions:

 

1. Ask for the user’s name and welcome them to the ordering system, using their name

2. Show the program menu:

(I) nformation (O)rder ticket (E) xit If the user chooses (I) display the following text:

“Thank you for choosing Tropical Airlines for your air travel needs. You will be asked questions regarding what type of ticket you would like to purchase as well as destination information. We also offer 50% discounted fares for children.”

If the user chooses (O) then the program will begin the process of ordering a ticket, as described below.

 

ALL other choices will produce an error. The menu will be displayed after every menu choice, except (E)

3. Once the (O) option has been entered, the program welcomes the user and asks if the ticket is for the user or for another person. If it is for another person, get the traveller’s name to display at the end, otherwise use the user’s name. For the following instructions you will need to keep track of the values and make all needed calculations at the end.

 

For this assignment you MUST ask the users for the following pieces of information in the order given, and you MUST allow for the specific inputs shown. Real world clients will often have the final say over the user interface, so this is a common restriction.

 

a. Ask if ticket will be one way or return (round trip)

b. Ask for the destination (choices are Cairns, Sydney or Perth).

c. Ask for the type of fare (Business, Economy or Frugal)

d. Ask what type of seat (Window, Aisle or Middle)

e. Ask age of person in order to check for child fare

f. Show user or traveller name, choices and total

4. If user chooses (E), the program should exit with the message: “[username], your orders are:” with a list of the ticket costs in ascending numerical order, then the message “Your final total is:” with the combined total and then the message “Thank you for visiting Tropical Airlines”.

Example: “[username], your orders are: $250, $300 and $550. Your final total is: $1100. Thank you for visiting Tropical Airlines.” You also must handle the situation where only one order is placed “[username], your order is: $250. Your final total is: $250. Thank you for visiting Tropical Airlines”.

 

 

Implementation:

Python file: You are to divide your solution into functions, following the principles shown in class. These may involve one for each menu option (other than Exit) as well as functions for parts of the program (e.g. a calculating the total ticket price could be implemented as a function). For each function you are to provide an IPO chart listing all variables which are needed for your solution. In cases where selections are necessary you must include a suitable condition action table directly below the IPO chart. Follow the sample solution provided in Assignment One as a guide.

 

Planning document:

You also need to provide an updated version of your previous planning document showing an algorithm in pseudocode for each function, being sure to clearly indicate input and output variables for each. This should be based on your submission for Assignment One, with appropriate changes being made for new functionality.

 

You may show your assignment to your tutor during practical time to get comments or suggestions. It is important to note that you can only get help from staff in practical time after your prac work is finished.

 

 

 

General Principles:

In this assignment, you will be focusing on basic planning and implementation using selections, repetition, and functions. Lists may be used where they are feasible.

 

Use the techniques and patterns that you have learned and seen demonstrated in class.

 

· You are allowed to use the code that Flowgorithm generates as a base for your project, although you will need to make additions to it:

· Flowgorithm does not create a main function, so you must do this at either the top or the bottom of your code

· Flowgorithm generated code does not always follow the best practices we have shown in lectures and pracs. Ensure that you do.

 

· Coding standards:

 

· Variables:

· Wherever possible, variables should be set at the top of the function

· Although Python does not use constants you may set variables to values that will remain the same for the life of the program. These should be named in all caps

· You should be able to modify these variables to adjust the various costs of items such as one-way fare, return, discount for child tickets, etc. This is one of the most important aspects of this assignment, so consider carefully how to use constants. Remember to use these variables everywhere you can.

· You will need to decide the best position to place these variables.

· You should AVOID the use of global variables unless they are needed in multiple places in the application

· In other words, you should pass the values to any functions that need them

· And any constants only needed in one function should be ONLY in that function

· Variables should be named appropriately using either camelCase or under_scores

· No variables should be a single character such as “x” or “y” unless they are used in a loop as an index. Variable names should be meaningful, and describe their use and/or purpose

· Any list variable should be named with plurals to show multiple data is held (e.g. prices versus price)

 

· Comments:

· You will need to add at LEAST one comment for each function that you define including main

· The comment should either be placed directly above or below the function header

· The comment should describe: (a) the purpose of the function, (b) any inputs and (c) any returned values

· Additional comments should be placed at any position where the functionality of the program may be unclear

· All code MUST BE properly indented

 

 

· Error handling:

· Note that menu choice and other character selection should handle upper and lower case letters.

· Look into the toUpper() or toLower() functions in Python

· You also must make sure that any functions that get input from the user do error checking to ensure that the input is within the expected range (greater than zero, etc).

 

· Output

· Make your output display as close as possible to the given examples, especially formatting and layout. Use Google to find out how to display tabs and other special characters using Python 3.

Hints:

· You may find a list variable useful for holding order costs

· You’ll need the cost of all orders to be stored in main, for display when the user quits. This may need to be returned from a function.

· Try to use pre-defined Python functions wherever possible (such as sort, total, len)

 

Submission:

Hand in a zip file (named like: FirstnameLastname) containing the following:

· Python file (.py)

· Planning document in Microsoft Word format (.docx)

 

Submit your zip file by uploading it on LearnJCU under Assessment.

 

Due:

Submit your assignment by the date and time specified on LearnJCU.

Submissions received after this date will incur late penalties as described in the subject outline.

Dot Image
Tutorials for this Question
  1. Tutorial # 00748027 Posted By: dr.tony Posted on: 01/21/2020 09:33 AM
    Puchased By: 2
    Tutorial Preview
    The solution of  CP1401 Assignment 2 -  Implement the Tropical Airlines program...
    Attachments
     CP1401_Assignment_2_-_ Implement_the_Tropical_Airlines_program.ZIP (18.96 KB)

Great! We have found the solution of this question!

Whatsapp Lisa