Advertisement
Guest User

Untitled

a guest
Nov 19th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. let AvailableBalance = 250000;
  2. let expense = (amount) => {
  3. AvailableBalance = AvailableBalance - amount;
  4. return `Expense = ${amount}$ Current Balance = ${AvailableBalance}$`;
  5. };
  6. let deposit = (amount) => {
  7. AvailableBalance = AvailableBalance + amount;
  8. return `Deposit = ${amount}$ Current Balance = ${AvailableBalance}$`;
  9. };
  10. let index = 0;
  11. var r1 = require('readline');
  12. var prompts = r1.createInterface(process.stdin, process.stdout);
  13. let i = 0;
  14. while (i === 0)
  15. {
  16. prompts.question('Do you want to deposit or withdrow? Enter d or w : ', function(input) {
  17. if (input === 'd') {
  18. prompts.question('Enter amount : ', function(amount) {
  19. index = index + 1;
  20. console.log(deposit(parseInt(amount)));
  21. process.exit();
  22. });
  23. }
  24. else if ( input === 'w') {
  25. prompts.question('Enter amount', function(amount) {
  26. index = index + 1;
  27. console.log(expense(parseInt(amount)));
  28. process.exit();
  29. });
  30. }
  31. else if ( input === 'end') {
  32. i = 1;
  33. }
  34. });
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement