python prgramming

User Generated

unewbgryrp

Programming

Description

Assignment 2

Value: 15%

Due Date: 26-Aug-2018

Return Date: 14-Sep-2018

Length:

Submission method options: Alternative submission method

Task

back to top

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:

  1. Unleaded 94 with E10
  2. Unleaded 91
  3. Unleaded 95
  4. Super Unleaded 98
  5. LPG
  6. 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:

  1. Unleaded 94 with E10 – 130.9
  2. Unleaded 91 – 132.9
  3. Unleaded 95 – 145.9
  4. Super Unleaded 98 - 153.9
  5. LPG – 71.9
  6. 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)
-----------------------------------------------------------------------

  1. Unleaded 94 with E10
  2. Unleaded 91
  3. Unleaded 95
  4. Super Unleaded 98
  5. LPG
  6. 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:

  1. Your algorithm through flowchart/s.
  2. The table recording your chosen test data and results (it can be in a Word or PDF file).
  3. Source code for your Python implementation.

Rationale

back to top

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

back to top

Criteria

High Distinction (85-100%)

Distinction (75-84%)

Credit (65-74%)

Pass (50-64%)

Fail (0-49%)

  • Explain the steps involved in a disciplined approach to problem-solving, algorithm development and coding,
  • demonstrate elements of good programming style

    (four marks allocated)

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

  • Identify, isolate and correct errors in all phases of the programming process.
  • Apply sound program analysis, design, coding, debugging, testing and documentation techniques to simple programming problems


(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.

  • Apply sound program analysis, design, coding, debugging, testing and documentation techniques to simple programming problems
  • Interpret algorithms and program code,
  • Write code in an appropriate language


(eight marks allocated)

Python code is produced and contains only necessary
statements and variables. Exceptions are handled properly.

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

back to top

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.docx.

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.docx.

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

back to top

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).

User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Explanation & Answer

Hey buddy, i have fin...


Anonymous
Excellent! Definitely coming back for more study materials.

Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4

Related Tags