Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Online Book Merchants has regular customers and premium customers. When a customer makes a purchase, a reward is given based on the following policies: If

Online Book Merchants has regular customers and premium customers. When a customer makes a purchase, a reward is given based on the following policies:
If a regular customer purchases at least 12 books, 2 free books are given. Otherwise, if a regular customer purchases at least 7 books, 1 free book is given. If a regular customer purchases less than 7 books, no free books are given.
If a premium customer purchases at least 8 books, 2 free books are given. Otherwise, if a premium customer purchases at least 5 books, 1 free book is given. If a premium customer purchases less than 5 books, no free books are given.
Assume the following variables have already been declared in a program:
A boolean variable named isPremiumCustomer. This variable is already assigned a value to indicate whether the customer is a premium customer.
An int variable named nbooksPurchased. This variable is already assigned the number of books the customer is purchasing.
An int variable named freeBooks. This variable has not been assigned a value.
Write a code snippet that determines the correct number of free books to be given to the customer. Your code snippet should assign this value to the freeBooks variable. (You will need to use nested if-else statements in your code.)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Management Databases And Organizations

Authors: Watson Watson

5th Edition

0471715360, 978-0471715368

More Books

Students also viewed these Databases questions