Guest User

Untitled

a guest
Jun 19th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. var origBank = prompt("What's your account balance?"); // passed in amount
  2. var spendingThreshold = prompt("What's your spending threshold?"); // passed in amount
  3. var bank = origBank;
  4. const PRICE = 20;
  5. const PRICE_ACCESSORIES = 10;
  6. const TAX_RATE = 0.0825;
  7.  
  8.  
  9. var number = 0;
  10. var numAccess = 0;
  11. var subTotal = 0;
  12. var total = 0;
  13.  
  14. function taxPaid(subTotal) {
  15. return(subTotal * TAX_RATE);
  16. }
  17. function subTotalCalc(number, numAccess) {
  18. subTotal = (number * PRICE) + (numAccess * PRICE_ACCESSORIES);
  19. return(subTotal)
  20. }
  21.  
  22. while (origBank > total) {
  23. number = number + 1;
  24. numAccess = numAccess + 1;
  25. total = subTotalCalc(number, numAccess) + taxPaid(subTotal);
  26. bank = origBank - total;
  27. console.log (number);
  28. console.log(numAccess);
  29. console.log("I've spent $" + total.toFixed(2) + " on phones and phone accessories so far today. I've got $" + bank.toFixed(2) + " left in the bank.");
  30. }
Add Comment
Please, Sign In to add comment