Ask Question
9 November, 11:24

Online Book Merchants offers premium customers 1 free book with every purchase of 5 or more books and offers 2 free books with every purchase of 8 or more books. It offers regular customers 1 free book with every purchase of 7 or more books, and offers 2 free books with every purchase of 12 or more books. Write a statement that assigns freeBooks the appropriate value based on the values of the boolean variable isPremiumCustomer and the int variable nbooksPurchased.

+3
Answers (1)
  1. 9 November, 12:14
    0
    A statement that assigns freeBooks the appropriate value based on the values of the boolean variable isPremiumCustomer and the int variable nbooksPurchased.

    if (nbooksPurchased > 4) {

    if (isPremiumCustomer) {

    freeBooks = 1;

    if (nbooksPurchased > 7) {

    freeBooks = 2;

    }

    }else{

    freeBooks = 0;

    if (nbooksPurchased > 6) {

    freeBooks = 1;

    }

    if (nbooksPurchased > 11) {

    freeBooks = 2;

    }

    }

    }else{freeBooks = 0; }
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Online Book Merchants offers premium customers 1 free book with every purchase of 5 or more books and offers 2 free books with every ...” in 📘 Business if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers