Advertisement
Luninariel

Financial Calculator - Main WIP

Nov 26th, 2019
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. This is a javascript calculation program. It is meant to assist the user in calculating several financial plans.
  3.  
  4. It Includes The Following:
  5.  
  6. * Simple Interest
  7. * Compound Interest
  8. * Splitting A Check Evenly Amongst Patrons, And Calculating The Tip.
  9.  
  10. Each calculator has its own files, and functions, and main drives them all.
  11. Each calculator is broken down to its base level functions to make debugging / updating / Adding easier.
  12. If An Invalid Input is detected, an error is returned and the relevant question is reloaded.
  13.  
  14. Functions are used frequently to ensure users stay on the right track, and allow for easier debugging
  15.  */
  16.  
  17. //Variables to refer to their specific calculator
  18. let Check = require("./CheckSplitter.js");
  19. let Simple = require("./SimpleInterest.js");
  20. let Compound = require("./Compound interest.js");
  21.  
  22. //Variable to read and analyze user input
  23. const readline = require('readline');
  24. const rl = readline.createInterface({
  25.     input: process.stdin,
  26.     output: process.stdout
  27. });
  28. main();
  29.  
  30. //The Main Function, asking users which calculator they'd like to use, and calling that function.
  31. function main() {
  32.     rl.question('\nWhich Calculator Would You Like To Use Today?\n' +
  33.         '\nPress 1 To Split A Check / Calculate The Tip\n' +
  34.         '\nPress 2 To Calculate Simple Interest\n'+
  35.         '\nPress 3 To Calculate Compound Interest',
  36.         (CalcChoose) => {
  37.         switch (CalcChoose) {
  38.             case '1':
  39.                 console.log("\nLoading Tip Calculator / Check Splitter \n");
  40.                 Check.CheckSplit();
  41.                 break;
  42.             case '2':
  43.                 console.log("\nLoading Simple Interest Calculator\n");
  44.                 Simple.principle();
  45.                 break;
  46.             case'3':
  47.                 console.log("\nLoading Compound Interest Calculator\n");
  48.                 Compound.principle();
  49.                 break;
  50.             default:
  51.                 console.log("\nYou've Entered An Invalid Response. Please Try Again\n");
  52.                 main();
  53.         }
  54.     });
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement