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.

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
Programming language C++
Another example run:
Enter purchases amount (-1 to quit input): 50e
Points earned with this transaction: 10
Total points : 10
Monetary value: R 2.50
bo you want to use your points (Y or N)? n
------- ..
------
Enter purchases amount (-1 to quit input): 600
Points earned with this transaction: 14
Total points : 24
Monetary value: R 6.e0
Do you want to use your points (Y or N)? n
--..
Enter purchases amount (-1 to quit input): 1000
Points earned with this transaction: 30
Total points : 54
Monetary value : R 17.9e
þiscount amount: R 50.ee
You have reached the maximum points limit.
You will receive the value of your points with this transaction.
Enter purchases amount (-1 to quit input): -1
Done
Another example run:
Enter purchases amount (-1 to quit input): 300
Points earned with this transaction: 6
Total points : 6
Monetary value: R 1.50
Do you want to use your points (Y or N)? n
Enter purchases amount (-1 to quit input): 250
Points earned with this transaction: 5
Total points : 11
Monetary value: R 2.75
Do you want to use your points (Y or N)? n
------
Enter purchases amount (-1 to quit input): 375
Points earned with this transaction: 7
Total points : 18
Monetary value: R 4.50
Do you want to use your points (Y or N)? n
------
Enter purchases amount (-1 to quit input): 1450
Points earned with this transaction: 48
Total points : 66
Monetary value : R 25.1e
You have reached the maximum points limit.
You will receive the value of your points with this transaction.
Enter purchases amount (-1 to quit input): -1
Done
Transcribed Image Text:Another example run: Enter purchases amount (-1 to quit input): 50e Points earned with this transaction: 10 Total points : 10 Monetary value: R 2.50 bo you want to use your points (Y or N)? n ------- .. ------ Enter purchases amount (-1 to quit input): 600 Points earned with this transaction: 14 Total points : 24 Monetary value: R 6.e0 Do you want to use your points (Y or N)? n --.. Enter purchases amount (-1 to quit input): 1000 Points earned with this transaction: 30 Total points : 54 Monetary value : R 17.9e þiscount amount: R 50.ee You have reached the maximum points limit. You will receive the value of your points with this transaction. Enter purchases amount (-1 to quit input): -1 Done Another example run: Enter purchases amount (-1 to quit input): 300 Points earned with this transaction: 6 Total points : 6 Monetary value: R 1.50 Do you want to use your points (Y or N)? n Enter purchases amount (-1 to quit input): 250 Points earned with this transaction: 5 Total points : 11 Monetary value: R 2.75 Do you want to use your points (Y or N)? n ------ Enter purchases amount (-1 to quit input): 375 Points earned with this transaction: 7 Total points : 18 Monetary value: R 4.50 Do you want to use your points (Y or N)? n ------ Enter purchases amount (-1 to quit input): 1450 Points earned with this transaction: 48 Total points : 66 Monetary value : R 25.1e You have reached the maximum points limit. You will receive the value of your points with this transaction. Enter purchases amount (-1 to quit input): -1 Done
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 wvill 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
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 eamed 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.00
þo you want to use your points (Y or N)? y
E-- -
Enter purchases amount (-1 to quit input): 178
Þoints earned with this transaction: 3
Total points : 3
Monetary value: R e.75
po you want to use your points (Y or N)? n
F---------
Enter purchases amount (-1 to quit input): 99
-------
Þoints earned with this transaction: 1
Total points : 4
Monetary value: R 1.00
po you want to use your points (Y or N)? n
E-------------------------------------------
Enter purchases amount (-1 to quit input): 49
Points earned with this transaction: e
Total points : 4
Monetary value: R 1.ee
þo you want to use your points (Y or N)? n
---------------------------------.
Enter purchases amount (-1 to quit input): -1
þone
Another example run:
Transcribed Image Text: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 wvill 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 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 eamed 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.00 þo you want to use your points (Y or N)? y E-- - Enter purchases amount (-1 to quit input): 178 Þoints earned with this transaction: 3 Total points : 3 Monetary value: R e.75 po you want to use your points (Y or N)? n F--------- Enter purchases amount (-1 to quit input): 99 ------- Þoints earned with this transaction: 1 Total points : 4 Monetary value: R 1.00 po you want to use your points (Y or N)? n E------------------------------------------- Enter purchases amount (-1 to quit input): 49 Points earned with this transaction: e Total points : 4 Monetary value: R 1.ee þo you want to use your points (Y or N)? n ---------------------------------. Enter purchases amount (-1 to quit input): -1 þone Another example run:
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Introduction to computer system
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.
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