Loyalty points are awarded by a company based on the amount a customer spend. Loyalty points can be used immediately with the current transaction or can be accumulated. The number of loyalty points per transaction is calculated as follows: For purchases of R 500.00 or less, 1 loyalty point will be awarded per R 50.00 spent. For purchases of more than R 500.00 the following applies: For the first R 500.00, 1 loyalty point will be awarded per R 50.00 spent • For the remainder of the amount, 2 loyalty points will be awarded per R50.00 spent. Examples: For purchases of R 460.00, 9 loyalty points will be awarded. For purchases of R 660.00, 10 loyalty points will be awarded for the first R 500.00 and 6 loyalty points for the remaining R 160.00 = 16 loyalty points For purchases of R 1250.00, 10 loyalty points will be awarded for the first R 500.00 and 30 loyalty points for the remaining R 750.00 = 40 loyalty points The monetary value of the loyalty points is calculated as follows: The first 30 loyalty points are worth 25c each. Loyalty points from 30 up to 50 is worth 40c each. Loyalty points above 50 is worth 60c each. With each transaction the customer can choose to use their loyalty points in which case the customer will receive the monetary value of the total number of loyalty points and the total will be set to 0. 1 If the total number of loyalty points reaches a total of 50 when a transaction takes place, the customer automatically receives the monetary value of the total number of points. If a total of 50 or more points is reached within 3 transactions, the customer also receives a 5% discount on the current purchase amount. Do the following: Write code to simulate a number of transactions done by one customer. The user must enter purchase amounts for a number of transactions. Use the value of -1 as purchase amount to quit input. • For each transaction display the number of loyalty points earned with the current transaction, the total number of loyalty points and the monetary value of the total number of loyalty points. • If the total number of points did not reach the value of 50 yet with the current transaction, the user must indicate whether the points will be used or not. If the points are used, the total number of points must be set to 0. If the total number of points reaches the value of 50 with the current transaction, the user does not have a choice to use the points. The points will automatically be used and the total number of points will be set to 0. A discount must be calculated and displayed if applicable.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
3G R
4G
O 53% D 17:57
CMPG 121 Final...
Loyalty points are awarded by a company based on the amount a customer spend. Loyalty points can be used
immediately with the current transaction or can be accumulated.
The number of loyalty points per transaction is calculated as follows:
For purchases of R 500.00 or less, 1 loyalty point will be awarded per R 50.00 spent.
For purchases of more than R 500.00 the following applies:
• For the first R 500.00, 1 loyalty point will be awarded per R 50.00 spent
For the remainder of the amount, 2 loyalty points will be awarded per R50.00 spent.
Examples:
For purchases of R 460.00, 9 loyalty points will be awarded.
For purchases of R 660.00, 10 loyalty points will be awarded for the first R 500.00 and 6 loyalty points for the
remaining R 160.00 = 16 loyalty points
For purchases of R 1250.00, 10 loyalty points will be awarded for the first R 500.00 and 30 loyalty points for the
remaining R 750.00 = 40 loyalty points
The monetary value of the loyalty points is calculated as follows:
The first 30 loyalty points are worth 25c each.
Loyalty points from 30 up to 50 is worth 40c each.
Loyalty points above 50 is worth 60c each.
With each transaction the customer can choose to use their loyalty points in which case the customer will receive
the monetary value of the total number of loyalty points and the total will be set to 0.
1
If the total number of loyalty points reaches a total of 50 when a transaction takes place, the customer
automatically receives the monetary value of the total number of points. If a total of 50 or more points is reached
within 3 transactions, the customer also receives a 5% discount on the current purchase amount.
Do the following:
Write code to simulate a number of transactions done by one customer.
The user must enter purchase amounts for a number of transactions. Use the value of -1 as purchase amount
to quit input.
For each transaction display the number of loyalty points earned with the current transaction, the total
number of loyalty points and the monetary value of the total number of loyalty points.
If the total number of points did not reach the value of 50 yet with the current transaction, the user must
indicate whether the points will be used or not. If the points are used, the total number of points must
be set to 0.
If the total number of points reaches the value of 50 with the current transaction, the user does not have
a choice to use the points. The points will automatically be used and the total number of points will be
set to 0. A discount must be calculated and displayed if applicable.
Example run:
Enter purchases amount (-1 to quit input): 227
Þoints earned with this transaction: 4
Total points : 4
Monetary value: R 1.00e
þo you want to use your points (Y or N)? y
Enter purchases amount (-1 to quit input): 178
Þoints earned with this transaction: 3
Total points : 3
Monetary value: R 0.75
þo you want to use your points (Y or N)? n
Enter purchases amount (-1 to quit input): 99
Þoints earned with this transaction: 1
Total points : 4
Monetary value: R 1.e0
þo you want to use your points (Y or N)? n
F------
Enter purchases amount (-1 to quit input): 49
Þoints earned with this transaction: e
Total points : 4
Monetary value: R 1.00
þo you want to use your points (Y or N)? n
-----.-
Enter purchases amount (-1 to quit input): -1
Done
Another example run:
Transcribed Image Text:3G R 4G O 53% D 17:57 CMPG 121 Final... Loyalty points are awarded by a company based on the amount a customer spend. Loyalty points can be used immediately with the current transaction or can be accumulated. The number of loyalty points per transaction is calculated as follows: For purchases of R 500.00 or less, 1 loyalty point will be awarded per R 50.00 spent. For purchases of more than R 500.00 the following applies: • For the first R 500.00, 1 loyalty point will be awarded per R 50.00 spent For the remainder of the amount, 2 loyalty points will be awarded per R50.00 spent. Examples: For purchases of R 460.00, 9 loyalty points will be awarded. For purchases of R 660.00, 10 loyalty points will be awarded for the first R 500.00 and 6 loyalty points for the remaining R 160.00 = 16 loyalty points For purchases of R 1250.00, 10 loyalty points will be awarded for the first R 500.00 and 30 loyalty points for the remaining R 750.00 = 40 loyalty points The monetary value of the loyalty points is calculated as follows: The first 30 loyalty points are worth 25c each. Loyalty points from 30 up to 50 is worth 40c each. Loyalty points above 50 is worth 60c each. With each transaction the customer can choose to use their loyalty points in which case the customer will receive the monetary value of the total number of loyalty points and the total will be set to 0. 1 If the total number of loyalty points reaches a total of 50 when a transaction takes place, the customer automatically receives the monetary value of the total number of points. If a total of 50 or more points is reached within 3 transactions, the customer also receives a 5% discount on the current purchase amount. Do the following: Write code to simulate a number of transactions done by one customer. The user must enter purchase amounts for a number of transactions. Use the value of -1 as purchase amount to quit input. For each transaction display the number of loyalty points earned with the current transaction, the total number of loyalty points and the monetary value of the total number of loyalty points. If the total number of points did not reach the value of 50 yet with the current transaction, the user must indicate whether the points will be used or not. If the points are used, the total number of points must be set to 0. If the total number of points reaches the value of 50 with the current transaction, the user does not have a choice to use the points. The points will automatically be used and the total number of points will be set to 0. A discount must be calculated and displayed if applicable. Example run: Enter purchases amount (-1 to quit input): 227 Þoints earned with this transaction: 4 Total points : 4 Monetary value: R 1.00e þo you want to use your points (Y or N)? y Enter purchases amount (-1 to quit input): 178 Þoints earned with this transaction: 3 Total points : 3 Monetary value: R 0.75 þo you want to use your points (Y or N)? n Enter purchases amount (-1 to quit input): 99 Þoints earned with this transaction: 1 Total points : 4 Monetary value: R 1.e0 þo you want to use your points (Y or N)? n F------ Enter purchases amount (-1 to quit input): 49 Þoints earned with this transaction: e Total points : 4 Monetary value: R 1.00 þo you want to use your points (Y or N)? n -----.- Enter purchases amount (-1 to quit input): -1 Done Another example run:
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 4 images

Blurred answer
Knowledge Booster
Problems on Dynamic Programming
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education