Write a python program

Assignment Help Python Programming
Reference no: EM13844508

W Mart, a new retail chain, has announced a discount on the total sale amount, in a single transaction, using the following scheme.

Table 1: Discount on Sale Amount

Total Sale AmountDiscount on this sale amount
Less than $100 0%
From $100 up to less than $500 10% for each dollar over $100
From $500 up to less than $1,000 $40 PLUS 20% of the total sale amount over $500
From $1,000 up to less than $2,000 $140 PLUS 30% of the total sale amount over $1,000
$2,000 and above $440 PLUS 40% of the total sale amount over $2,000

That is, if the total sale amount is $100 then the discount will be $0. However, if the total sale amount is $101 then the discount will be $0.10. If the total sale amount is $500 then the discount will be $40, but if the total sale amount is $501 then the discount will be $40.20.

W Mart keeps track of a customer through a unique customer ID. W Mart gives one reward point for every $100 spent irrespective of the number of transactions. The points accumulate over the time for a customer for his/her purchases. Finally, for each 100 reward points it gives an additional discount of $10 on a purchase over $10 in a transaction.

Write a Python program that, for every transaction, takes input on the customer ID and the total sale amount in the transaction. It then reads a text file called discount.txt that stores information on the discount on sales amount as shown in Table 1 above. The text file stores the information in a plain text format as follows.

Less than $100 --> 0%

From $100 up to less than $500 --> 10%

From $500 up to less than $1,000 --> $40 PLUS 20%

From $1,000 up to less than $2,000 --> $140 PLUS 30%

$2,000 and above --> $440 PLUS 40%

At the end of each transaction, the information related to the transaction would be displayed on the screen. Please see the example as follows.

Customer ID: 1Total sale amount: 110Discount amount: 1Discounted sale amount: 109Reward point: 1Additional discount: 0Additional discounted sale amount: 109Cumulative sale amount for the next reward point: 10Final sale amount: 109Moreover, at the end of each transaction, the information related to the transaction needs to be written (appended) out in a file called sales.txt in the following way:1 110 1 109 1 0 109 10 109However, next time if the same customer spends $50 then the following lines should be displayed on the screen.

Customer ID: 1Total sale amount: 50Discount amount: 0Discounted sale amount: 50Reward point: 1Additional discount: 0Additional discounted sale amount: 50Cumulative sale amount for the next reward point: 60Final sale amount: 50 and 1 50 0 50 1 0 50 60 50 would be written (appended) in the salex.txt file.Again, if the same customer spends $40 then the following lines should be displayed on the screen.Customer ID: 1Total sale amount: 40Discount amount: 0Discounted sale amount: 40Reward point: 2Additional discount: 0Additional discounted sale amount: 40Cumulative sale amount for the next reward point: 0Final sale amount: 40and 1 40 0 40 2 0 40 0 40 would be written (appended) in the salex.txt file.

Use appropriate data structure in writing your code.

All exceptions need to be handled. Invalid inputs need to be handled and asked for a valid input again.

Use functions to make your program well designed, instead of just using a single main function. For example, you could use a function to take inputs from a user, a function to compute the discount, a function to compute the reward points, a function to display the output on the screen and so on. We expect you to use at least four (4) functions other than the main function.

In order to compute the reward points of a customer your program will need to read the sales.txt file. A customer is identified by her/his unique Customer ID, and may appear multiple times in the sales.txt file.

Implement your algorithm in Python.

Avoid duplicate code.

Comment your code as necessary to explain it clearly.

Select 3 sets of test data that will demonstrate the correct "normal" operation of your program.
Run your program using the test data you have selected and save the output it produces in a text file.

Submit:
1. Your algorithm.
2. The table recording your chosen test data.
3. Source code for your Python implementation.
4. Output listings demonstrating the results of using the test data.

It is important that the output listings are not edited in any way

 

 

Reference no: EM13844508

Questions Cloud

Which words frequently indicate a pivot : what pivots are. which words frequently indicate a pivot. why it is important to be aware of pivots when you read
It consultant to upgrade to a fast ethernet network : Price out everything for this. You will need to list what client computers you will suggest including the details of these machines, along with what networking hardware you decided they should use, and most importantly why you are suggesting it.
Write essay on effective communication : Effective Communication- Training Needs Assessment. summarizing how this training will be effective and how it should be evaluated.
Find the general solution for system of equations : Find the general solution for system of equations with respect to the basic matrix B = (-a1 -a2 -a4), where -ai represents the ith, column of A.
Write a python program : Write a Python program
Identify a goal for improvement for each fitness area : Identify a goal for improvement for each fitness area (aerobic, muscular strength/endurance, BMI, and body composition)
Write one page paper on five concept from the given article : Write a one page paper on five concept from the article "Money-changers at bay". Can anyone help me find five concepts to write about?
Write a program for recursive algorithm : Consider the following recursive algorithm
Financing portion of panera bread company : Complete the financing portion of Panera Bread Company's 2007 forecast financial statements, and provide a forecast for the next five years.

Reviews

Write a Review

Python Programming Questions & Answers

  Write a python program to implement the diff command

Without using the system() function to call any bash commands, write a python program that will implement a simple version of the diff command.

  Write a program for checking a circle

Write a program for checking a circle program must either print "is a circle: YES" or "is a circle: NO", appropriately.

  Prepare a python program

Prepare a Python program which evaluates how many stuck numbers there are in a range of integers. The range will be input as two command-line arguments.

  Python atm program to enter account number

Write a simple Python ATM program. Ask user to enter their account number, and print their initail balance. (Just make one up). Ask them if they wish to make deposit or withdrawal.

  Python function to calculate two roots

Write a Python function main() to calculate two roots. You must input a,b and c from keyboard, and then print two roots. Suppose the discriminant D= b2-4ac is positive.

  Design program that asks user to enter amount in python

IN Python Design a program that asks the user to enter the amount that he or she has budget in a month. A loop should then prompt the user to enter his or her expenses for the month.

  Write python program which imports three dictionaries

Write a Python program called hours.py which imports three dictionaries, and uses the data in them to calculate how many hours each person has spent in the lab.

  Write python program to create factors of numbers

Write down a python program which takes two numbers and creates the factors of both numbers and displays the greatest common factor.

  Email spam filter

Analyze the emails and predict whether the mail is a spam or not a spam - Create a training file and copy the text of several mails and spams in to it And create a test set identical to the training set but with different examples.

  Improve the readability and structural design of the code

Improve the readability and structural design of the code by improving the function names, variables, and loops, as well as whitespace. Move functions close to related functions or blocks of code related to your organised code.

  Create a simple and responsive gui

Please use primarily PHP or Python to solve the exercise and create a simple and responsive GUI, using HTML, CSS and JavaScript.Do not use a database.

  The program is to print the time

The program is to print the time in seconds that the iterative version takes, the time in seconds that the recursive version takes, and the difference between the times.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd