Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Nov 2nd, 2011  |  syntax: Java  |  size: 0.71 KB  |  views: 1,577  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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.