Python program that first displays a main menu

Assignment Help Basic Computer Science
Reference no: EM13934661

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 Amount Discount 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 first displays a main menu as follows and waits for a user to choose an option. A user needs to select an option from the main menu.

Welcome to W Mart:

Please choose an option from the followings.

<A>dd a new transaction of a customer to the database.
<D>elete the last transaction from the database for a given customer ID.
<Q>uit.

If a user selects the option <A> then the program takes input for a transaction. For a transaction, the program 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 following information is written (appended) out in a file called sales.txt. The same information is also displayed on screen.

Customer ID: 1
Total sale amount: 110
Discount amount: 1
Discounted sale amount: 109
Reward point: 1
Additional discount: 0
Additional discounted sale amount: 109
Cumulative sale amount for the next reward point: 10

Final sale amount: 109

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.

After displaying the transactional information the program will again display the main menu and wait for a user to choose an option.
Now, if a user selects the option <D> then the program should prompt the user to enter a customer ID for which the last transaction will be deleted from the sales.txt file. If the given Customer ID is found in the sales.txt file, the program should first collect and display the last transaction of the customer and then delete the information from the sales.txt file. Otherwise, the program should display a message reporting that "The customer does not exist in the database."
The program will then display the main menu again and wait for a user to choose an option.

Finally, the program should quit if a user chooses the option <Q>.
Note that a user can choose any of the three options whenever the main menu is displayed and the program should respond accordingly.
Use appropriate data structure in writing your code.
All exceptions need to be handled. Invalid inputs need to be handled and the program should ask 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 add a new transaction for a customer, 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, a function to delete the details of a customer, and so on. We expect you to use at least four (4) functions other than the main function.

Write an algorithm in structured English (pseudocode) that describes the steps required to perform the task specified. Some examples of pseudocode can be found at https://www.unf.edu/~broggio/cop2221/2221pseu.htm.

Implement your algorithm in Python.

Avoid duplicate code. For example, do not calculate the reward points in multiple places in your code. One way to do this is by an appropriate use of functions.

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: EM13934661

Questions Cloud

Standard deviation of the minimum variance portfolio : The stock of Bruin, Inc., has an expected return of 16 percent and a standard deviation of 31 percent. The stock of Wildcat Co. has an expected return of 11 percent and a standard deviation of 46 percent. The correlation between the two stocks is .31..
Plowback ratios stock price p-e ratio growth rate : Stormy Weather has no attractive investment opportunities. Its return on equity equals the discount rate, which is 10%. Its expected earnings this year are $2 per share. Find the stock price, P/E ratio, and growth rate of dividends for plowback ratio..
What relative values would intrinsic binding constants have : If the hemoglobin tetramer had four identical non-interacting binding sites, what relative values would the intrinsic binding constants have?
What is the price-earnings ratio of the company : No-Growth Industries pays out all of its earnings as dividends. It will pay its next $3 per share dividend in a year. The discount rate is 16%. What is the price-earnings ratio of the company?
Python program that first displays a main menu : 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..
Information on states of the economy and stock returns : Use the following information on states of the economy and stock returns to calculate the standard deviation of returns.
How could this mutant phenotype result : A mutant strain of E.coli has constitutive expression of the trp operon. How could this mutant phenotype result? Ideas are explained.
How much does the bluebird company need to deposit today : The Bluebird Company has a $10,000 liability it must pay three years from today. The company is opening a savings account so that the entire amount will be available when this debt needs to be paid. The plan is to make an initial deposit today and th..
Prepare a journal entry to record overhead applied to jobs : Prepare a journal entry to record overhead applied to jobs.

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Identifies the cost of computer

identifies the cost of computer components to configure a computer system (including all peripheral devices where needed) for use in one of the following four situations:

  Input devices

Compare how the gestures data is generated and represented for interpretation in each of the following input devices. In your comparison, consider the data formats (radio waves, electrical signal, sound, etc.), device drivers, operating systems suppo..

  Cores on computer systems

Assignment : Cores on Computer Systems:  Differentiate between multiprocessor systems and many-core systems in terms of power efficiency, cost benefit analysis, instructions processing efficiency, and packaging form factors.

  Prepare an annual budget in an excel spreadsheet

Prepare working solutions in Excel that will manage the annual budget

  Write a research paper in relation to a software design

Research paper in relation to a Software Design related topic

  Describe the forest, domain, ou, and trust configuration

Describe the forest, domain, OU, and trust configuration for Bluesky. Include a chart or diagram of the current configuration. Currently Bluesky has a single domain and default OU structure.

  Construct a truth table for the boolean expression

Construct a truth table for the Boolean expressions ABC + A'B'C' ABC + AB'C' + A'B'C' A(BC' + B'C)

  Evaluate the cost of materials

Evaluate the cost of materials

  The marie simulator

Depending on how comfortable you are with using the MARIE simulator after reading

  What is the main advantage of using master pages

What is the main advantage of using master pages. Explain the purpose and advantage of using styles.

  Describe the three fundamental models of distributed systems

Explain the two approaches to packet delivery by the network layer in Distributed Systems. Describe the three fundamental models of Distributed Systems

  Distinguish between caching and buffering

Distinguish between caching and buffering The failure model defines the ways in which failure may occur in order to provide an understanding of the effects of failure. Give one type of failure with a brief description of the failure

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