Advertisement
Guest User

Untitled

a guest
Nov 2nd, 2011
1,953
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.71 KB | None | 0 0
  1.  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.
  2.  
  3.  Write a statement that assigns  freeBooks the appropriate value based on the values of the bool variable  isPremiumCustomer and the int variable nbooksPurchased .
  4.  
  5.  
  6. Code:
  7.  
  8. if(isPremiumCustomer==true){
  9.     if(nbooksPurchased>=8){
  10.         freeBooks=2;
  11.     }
  12.     else if(nbooksPurchased>=5){
  13.         freeBooks=1;
  14.     }
  15. }
  16. else {
  17.    
  18.     if(nbooksPurchased>=12){
  19.         freeBooks=2;
  20.     }
  21.     else if(nbooksPurchased>=7){
  22.         freeBooks=1;
  23.     }
  24. }
  25.  
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement