You are writing a program for a bookstore that has a membership rewards program. This membership program has two versions: a free version and a paid version. Both free and paid members receive points when making purchases, and paid members also receive a 10% discount on their total order. Customers who are not a part of the membership program receive no rewards. Have your program run in a continuous while loop until the user decides to quit. Create a variable before the while loop called grand_total, initialized to 0. Each time a sale is entered, you will add the total to that variable. At the start of each loop iteration, the user has three options: Enter a new customer sale into the system. Ask how many books the customer is buying. Ask for the subtotal cost of the books, before tax. Ask whether the customer is a free member, paid member, or non-member. Calculate 9.25% of the subtotal cost to be the amount for taxes and add that amount to the subtotal to calculate the final cost. If the customer is a paid member, remove 10% of the subtotal cost from the final cost. (Note: The tax amount is not discounted) Add the final cost to the grand_total variable. Determine how many points the customer will receive for this purchase. If the customer is not a member, they receive 0 points. Otherwise, the number of points earned by the customer is based on the following list: If 1 book is purchased, all members earn 5 points. If 2 books are purchased, all members earn 15 points. If 3 books are purchased: Paid members earn 50 points Free members earn 30 points If 4 or more books are purchased Paid members earn 100 points Free members earn 60 points Display the following, one per row: # books the customer is purchasing, the subtotal, the tax amount, the final cost, the amount saved (only if they are a paid member, otherwise do not print this row), and po
Types of Loop
Loops are the elements of programming in which a part of code is repeated a particular number of times. Loop executes the series of statements many times till the conditional statement becomes false.
Loops
Any task which is repeated more than one time is called a loop. Basically, loops can be divided into three types as while, do-while and for loop. There are so many programming languages like C, C++, JAVA, PYTHON, and many more where looping statements can be used for repetitive execution.
While Loop
Loop is a feature in the programming language. It helps us to execute a set of instructions regularly. The block of code executes until some conditions provided within that Loop are true.
You are writing a
Have your program run in a continuous while loop until the user decides to quit. Create a variable before the while loop called grand_total, initialized to 0. Each time a sale is entered, you will add the total to that variable. At the start of each loop iteration, the user has three options:
- Enter a new customer sale into the system.
- Ask how many books the customer is buying.
- Ask for the subtotal cost of the books, before tax.
- Ask whether the customer is a free member, paid member, or non-member.
- Calculate 9.25% of the subtotal cost to be the amount for taxes and add that amount to the subtotal to calculate the final cost.
- If the customer is a paid member, remove 10% of the subtotal cost from the final cost. (Note: The tax amount is not discounted)
- Add the final cost to the grand_total variable.
- Determine how many points the customer will receive for this purchase. If the customer is not a member, they receive 0 points. Otherwise, the number of points earned by the customer is based on the following list:
- If 1 book is purchased, all members earn 5 points.
- If 2 books are purchased, all members earn 15 points.
- If 3 books are purchased:
- Paid members earn 50 points
- Free members earn 30 points
- If 4 or more books are purchased
- Paid members earn 100 points
- Free members earn 60 points
- Display the following, one per row: # books the customer is purchasing, the subtotal, the tax amount, the final cost, the amount saved (only if they are a paid member, otherwise do not print this row), and points received for this purchase. Make sure to format this information nicely.
- See how much money the store has made today.
- Print out how much money the store has made today (by printing the grand_total variable)
- Quit the program.
- Exit out of the while loop at this point. Before closing the program, print out how much money the store made today
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 1 images