Guest User

Untitled

a guest
Apr 25th, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. <cfscript>
  2.  
  3. getAccountBalance = function(){
  4. var balance = 120000;
  5. return balance;
  6. }
  7. function payCreditCardBill(accountBalance){
  8. var ccBill = 1890;
  9. return accountBalance-ccBill;
  10. }
  11. payEMIs = function(accountBalance){
  12. var mortgageEMI = 1000;
  13. var carLeaseEMI = 750;
  14. var healthInsuranceEMI = 250;
  15. return accountBalance-(mortgageEMI+carLeaseEMI+healthInsuranceEMI);
  16. }
  17. miscellenousExpenses = function(accountBalance){
  18. var shopping = 1500;
  19. var clubExpense =1000;
  20. var casinoExpense = 2000;
  21. return accountBalance-(shopping+clubExpense+casinoExpense);
  22. }
  23. checkBalance = function(accountBalance){
  24. while(accountBalance > 5000){
  25. accountBalance = miscellenousExpenses(accountBalance);
  26. writeOutput("checkBalance = " & accountBalance & "<br/>");
  27. }
  28. if(accountBalance < 5000)
  29. throw (message="Account balance below threshold!!!",
  30. type="info");
  31. }
  32. errorHandler = function(error){
  33. if(error.message contains "Account balance below threshold!"){
  34. return "You have reached your spending limit!";
  35. }
  36. }
  37. future = runAsync(getAccountBalance)
  38. .then(payCreditCardBill)
  39. .then(payEMIs)
  40. .then(miscellenousExpenses)
  41. .then(checkBalance)
  42. .error(errorHandler);
  43. writeOutput(future.get());
  44. </cfscript>
Add Comment
Please, Sign In to add comment