Answer:
Following are the if/else statement that are given below
if(nbooksPurchased > 4) //book purchase greater then 4
{
if(isPremiumCustomer) // check condition
{
freeBooks = 1; // free book is 1
if(nbooksPurchased > 7) // book purchase is 8
{
freeBooks = 2; // two free books
}
}
else
{
freeBooks = 0; // free books is 2
}
if(nbooksPurchased > 6) // book purchase is greater then 6
{
freeBooks = 1; // free books is 1
}
if(nbooksPurchased > 11) // book purchase is 12
{
freeBooks = 2; // free books is 2
}
}
}
else
{
freeBooks = 0; // free books is 0
}
Step-by-step explanation:
Following are the description of statement
- As mention in the question the variable "nbooksPurchased." described the purchasing of books ,"freeBooks" is used to describe the free books and "isPremiumCustomer" is bool variable .
- if nbooksPurchased >5 means the book is every purchase of the 5 it assign freeBooks = 1; .
- If nbooksPurchased is greater then 7 then free books variable is assigned with the 2 otherwise free books is 0.
- if nbooksPurchased is greater then 6 then it assign free books to 1.
- if nbooksPurchased is greater then 11 then it assign the free books to 2 otherwise assign freebooks to 0.