python prgramming
Assignment 2
Value: 15%
Due Date: 26-Aug-2018
Save your time - order a paper!
Get your paper written from scratch within the tight deadline. Our service is a reliable solution to all your troubles. Place an order on any task and we will take care of it. You won’t have to worry about the quality and deadlines
Order Paper NowReturn Date: 14-Sep-2018
Length:
Submission method options: Alternative submission method
Task
The owner of the local fuel station mentioned in the Assignment 1 wants to introduce a discount system for his customers. He wants to improve the program in Assignment 1 to calculate the cost of fuel for his customers and to show how much they save as discounts.
The program will ask a user to select a fuel type and enter the amount of fuel pumped. A user is expected to first select a fuel type from 6 candidate types:
- Unleaded 94 with E10
- Unleaded 91
- Unleaded 95
- Super Unleaded 98
- LPG
- Diesel
The user will enter the type of fuel as an option from 1 to 6. The program should then display the selected fuel type and ask the user for the amount of fuel in litres (floating-point numbers with 2 decimal points) for calculating the cost. Once the cost has been calculated, the program should correctly display the cost (a floating-point value with two decimal points) for the user.
For example, if a user selects “1†as the fuel type and enters “27.6” as the number of litres, the program should be able to display an cost of AUD($) “XXX.XX” for the user. The price of each fuel type should be given as a constant in the program. All the fuel prices are in cents. But, the cost should be displayed in AUD($) with 2 decimal points.
The fuel prices for the current date are as follows:
- Unleaded 94 with E10 – 130.9
- Unleaded 91 – 132.9
- Unleaded 95 – 145.9
- Super Unleaded 98 – 153.9
- LPG – 71.9
- Diesel – 125.9
Your program should be able to handle some exceptions such as invalid inputs, undefined fuel types, and invalid fuel volumes (0 to 11,000 are to be considered as valid).
The discounts are given as follows:
Discount Policy Table |
|
Cost of Fuel |
Bonus mark |
Between 0 and 20 |
Nil |
Greater than 20, but less than or equal to 30 |
10% of every dollar above $20 |
Greater than 30, but less than or equal to 50 |
3 dollars PLUS 15% of every dollar above 30 |
Greater than 50, but less than or equal to 150 |
6 dollars PLUS 20% of every dollar above 50 |
For example, if a customer spends AUD ($) 80 then he/she gets a discount of $12. Hence, the cost will be $68.
However, the maximum possible discount is $26. That is, if a customer spends more than $150 with the discount then the cost is set to be $124. After calculating the fuel cost for a customer, the system will then ask the user ‘Do you want to enter fuel volume for another customer (Y/N)?’
- If ‘Y’ is entered, the system will allow the user to enter details and volume for another customer as before.
- If ‘N’ is entered, the program terminates, otherwise, it will ask the same question again.
A typical example of the display of your program can be as follows. Your program MUST follow the same display style.
——————————
Welcome to Cheap Fuel Station (CFS)
—————————–
- Unleaded 94 with E10
- Unleaded 91
- Unleaded 95
- Super Unleaded 98
- LPG
- Diesel
Please select the fuel type you would like to calculate the cost for (1-6): 2
Thank you!
The fuel type you selected is: Unleaded 91
Please input the volume (in litres): 50.00
The cost of the fuel is AUD($): 66.45
You saving in this purchase is AUD($): 9.29
The cost of the fuel after discount is AUD($): 57.16
Thanks for using CFS Fuel cost calculator!
See you again!
Do you want to enter fuel volume for another customer (Y/N)? Y
Please select the fuel type you would like to calculate the cost for (1-6): 2
Thank you!
The fuel type you selected is: Unleaded 91
Please input the volume (in litres): 60.00
The cost of the fuel is AUD($): 79.74
You saving in this purchase ($): 11.95
The cost of the fuel after discount is AUD($): 67.79
Thanks for using CFS Fuel cost calculator!
See you again!
Do you want to enter fuel volume for another customer (Y/N)? N
See you again!
Your program should be able to handle invalid inputs such as negative volumes; volume is not-a-number or volume greater than 11,000.
You need to develop the Fuel Cost Calculation System by completing the following three tasks:
Task 1 –
Draw flowchart/s that present the steps of the algorithm required to perform the task specified.
Task 2 –
Select three sets of test data that will demonstrate the ‘normal’ operation of your program; that is, test data that will demonstrate what happens when a VALID input is entered. Select two sets of test data that will demonstrate the ‘abnormal’ operation of your program.
Set it out in a tabular form as follows: test data type, test data, the reason it was selected, the output expected due to using the test data, and finally the output actually observed when the test data is used. It is important that the output listings (i.e., screenshots) are not edited in any way.
Test Data Table |
||||
Test data type |
Test data |
The reason it was selected |
The output expected due to the use of the test data |
The screenshot of actual output when the test data are used |
Normal |
||||
Normal |
||||
Normal |
||||
Abnormal |
||||
Abnormal |
Task 3 –
Implement your algorithm in Python. Comment on your code as necessary to explain it clearly. Run your program using the test data you have selected and complete the test data table above.
Your submission will consist of:
- Your algorithm through flowchart/s.
- The table recording your chosen test data and results (it can be in a Word or PDF file).
- Source code for your Python implementation.
Rationale
This assessment task will assess the following learning outcome/s:
- be able to analyse the steps involved in a disciplined approach to problem-solving, algorithm development and coding.
- be able to demonstrate and explain elements of good programming style.
- be able to identify, isolate and correct errors; and evaluate the corrections in all phases of the programming process.
- be able to interpret and implement algorithms and program code.
- be able to apply sound program analysis, design, coding, debugging, testing and documentation techniques to simple programming problems.
- be able to write code in an appropriate coding language.
This assessment task is designed to reinforce topic material related to: decision structures and Boolean logic.
Marking criteria and standards
Criteria |
High Distinction (85-100%) |
Distinction (75-84%) |
Credit (65-74%) |
Pass (50-64%) |
Fail (0-49%) |
|
Flowchart/s do not have any unnecessary component. |
Flowchart/s are presented where all variable names are meaningful. |
Flowchart/s follow the convention, they are free of errors, and they produce the algorithm correctly. |
Flowchart/s follow the convention and contain three or fewer errors |
Flowchart/s follow the convention but contain more than three errors |
(three marks allocated) |
Test data explore every branch of the program. A clear explanation is provided of the expected output of the test results. AND The presented test output is in the form specified in the assignment. |
Sound reasons are provided for the selection of test data. AND The test output is correct for any test data in addition to those used in the submitted table to report the test result. |
Selected test data present both normal and abnormal data. AND The presented test output is correct. |
Selected test data are clearly presented in a table and allow easy calculation of output. AND The presented test output matches the actual results that can be obtained from the execution of the program. |
Selected test data are not clearly presented in a table and/or do not allow easy calculation of output. Or The presented test output does not match the actual results that can be obtained from the execution of the program. |
(eight marks allocated) |
Python code is produced and contains only necessary |
Python code is produced and implements the flowchart/s consistently. |
Python code is produced. It is fully documented with appropriate comments and all variable names are meaningful. |
Python code is produced and executes properly without any syntax errors. It produces correct results. |
Python code is produced and does not execute properly. It may contain syntax errors and/or produce incorrect results. |
Additional Comments: The standards outlined for each criterion are cumulative. So, for example, to achieve the standard for high distinction your work needs also to meet the standards outlined for Pass, Credit and Distinction.
Presentation
You have to prepare and present all source code, test data table, and flowchart/s separately and include them all in a single MS Word file identified by your name. See the ‘Requirements’ section below. The Python source code you write should be saved with a name such as ITC558assignment2YourName.py and then include a copy of it as text in the MS Word file named ITC558assignment2YourName.
The other parts of the assignment (such as your flowchart/s and your table of test data) should be included in the same MS Word file and save as ITC558assignment2YourName.
It is critically important that your test runs are unmodified outputs from your program, and that these results should be reproducible by the marker running your saved ITC558assignment2YourName.py python program.
Requirements
You have to save all the parts of the assignment (as described under ‘Presentation’ above) into a single MS Word document identified by your name as outlined in the section on presentation.
Failure to adhere to these requirements may disqualify the submission for marking.
Submit your complete assignment in MS Word format to Turnitin and e-mail your program source code to your subject lecturer (to an e-mail address given by the subject lecturer).