Cnvmendoza

Test Bank

Nov 16th, 2021 (edited)
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 10.50 KB | None | 0 0
  1. #include <cmath>
  2.  
  3. //Banking System
  4. float debt = 0;
  5. float bankMoney = 0;
  6. float interest = 5.00; // Note: Please replace this with a randomizer percentage between 5 to 10.8 percent. Thanks.
  7. float interest2 = 3.00; // NOte: Please put a randomizer range between 2 - 3%. Thanks
  8. float loan1 = 0;
  9. float loan2 = 0; //loan2 = 0 once the user has successfully traded.
  10. float lastDeposit = 0;
  11. float lastDeposit2 = 0;
  12.  
  13. //Remember Bank
  14. int memBank = 0;
  15. int memLoan = 0;
  16. int memDp = -1;
  17. int memDp2 = 0;
  18. int memDebt = 0;
  19.  
  20. //The Bank Function
  21. void theBank(void);
  22. void rules(void);
  23.  
  24. // User Debt Function
  25. void userDebt(void);
  26.  
  27. // Withdraw Function
  28. void withdraw(void);
  29.  
  30. // Deposit Function
  31. void deposit(void);
  32. void reports(void);
  33.  
  34. // Loan Function
  35. void loan(void);
  36. void repay(void);
  37. void borrow(void);
  38. void trust(void);
  39. void trusted(void);
  40. void checkDebt(void);
  41.  
  42.  
  43. // Compounding Bank Money Function
  44. void compoundBank(void);
  45.  
  46. //The Bank Function
  47. void theBank(void){
  48.     string input;
  49.     memBank = 0;
  50.     balance_balance();
  51.     cout << endl;
  52.     for (int i = 0; i > 15; i++){
  53.         cout << " ";
  54.     }
  55.     cout << endl;
  56.     cout << "Welcome to Jasper's Bank!";
  57.     cout << endl;
  58.     for (int i = 0; i > 15; i++){
  59.         cout << " ";
  60.     }
  61.     cout << endl;
  62.     cout << "What do you wish to do?";
  63.     cout << endl;
  64.     cout << setw(17);
  65.     cout << "[1] " << setw(15) << "Withdraw";
  66.     cout << endl;
  67.     cout << setw(17);
  68.     cout << "[2] " << setw(15) << "Deposit";
  69.     cout << endl;
  70.     cout << setw(17);
  71.     cout << "[3] " << setw(15) << "Loan"
  72.     cout << endl;
  73.     cout << setw(17);
  74.     cout << "[4] " << setw(15) << "Check Debt";
  75.     cout << endl;
  76.     cout << setw(17);
  77.     cout << "[5] " << setw(15) << "Deposit Report";
  78.     cout << endl;
  79.     cout << setw(17);
  80.     cout << "[6] " << setw(15) << "Rules";
  81.     cout << endl;
  82.     cout << setw(17);
  83.     cout << "[7] " << setw(15) << "Return";
  84.     cout << endl;
  85.     cout << setw(27);
  86.     cout << "Enter Input: ";
  87.     cin >> input;
  88.     if (input == "1"){
  89.         withdraw();
  90.     }
  91.     else if (input == "2"){
  92.         deposit();
  93.     }
  94.     else if (input == "3"){
  95.         loan();
  96.     }
  97.     else if (input == "4"){
  98.         checkDebt();
  99.     }
  100.     else if (input == "5"){
  101.         rules();
  102.     }
  103.     else if (input == "6"){
  104.         reports();
  105.     }
  106.     else if (input == "7"){
  107.         loc();
  108.     }
  109.     else theBank();
  110. }
  111.  
  112. // User Debt Function
  113. void userDebt(void){
  114.     turnl
  115. }
  116.  
  117. // Withdraw Function
  118. void withdraw(void){
  119.     balance_balance();
  120.     cout << endl;
  121.     cout << "How much money do you wish to withdraw?";
  122.     cout << endl;
  123.     cout << "Enter Input: Eur ";
  124.     cin >> wd;
  125.     if (wd < 0){
  126.         cout << endl;
  127.         cout << "Invalid input. Please try again!";
  128.         cout << endl;
  129.         system("pause");
  130.         withdraw();
  131.     }
  132.     else if (wd > bankMoney){
  133.         if (memDp2 == 1){
  134.             cout << endl;
  135.             cout << "You've just recently deposited Eur " << bankMoney2 << ".";
  136.             cout << endl;
  137.             cout << "Please wait for another turn . . . ";
  138.             cout << endl;
  139.             theBank();
  140.         }
  141.         cout << endl;
  142.         cout << "You do not have that amount in your bank account . . . ";
  143.         cout << endl;
  144.         system("pause");
  145.         withdraw();
  146.     }
  147.     else if (wd <= bankMoney){
  148.         if (memDp2 == 1){
  149.             cout << endl;
  150.             cout << "You've just recently deposited Eur " << bankMoney2 << ".";
  151.             cout << endl;
  152.             cout << "Please wait for another turn . . . ";
  153.             cout << endl;
  154.             theBank();
  155.         }
  156.         cout << endl;
  157.         cout << "You withdrew Eur " << wd << " to your balance . . . ";
  158.         cout << end;
  159.         cout << "Your balance has been updated . . . "
  160.         balance += wd;
  161.         bankMoney -= wd;
  162.         if (bankMoney == 0){
  163.             memDp = 0;
  164.         }
  165.         system("pause");
  166.         theBank();
  167.     }
  168. }
  169.  
  170. // Deposit Function
  171. void deposit(void){
  172.     balance_balance();
  173.     float dp;
  174.     float interest;
  175.     cout << endl;
  176.     cout << "How much money do you wish to deposit?";
  177.     cout << "Compound Interest: " << interest << "%"; // Note: Please replace this with a randomizer percentage between 5 to 10.8 percent. Thanks.
  178.     cout << endl;
  179.     cout << "Enter Input: Eur ";
  180.     cin >> dp;
  181.     if (dp < 0){
  182.         cout << endl;
  183.         cout << "Invalid input. Please try again . . . ";
  184.         cout << endl;
  185.         system("pause");
  186.         deposit();
  187.        
  188.     }
  189.     else if (dp > balance){
  190.         cout << endl;
  191.         cout << "You do not have that amount of money in your balance . . . ";
  192.         cout << endl;
  193.         system("pause");
  194.         deposit();
  195.     }
  196.     else if (dp <= balance){
  197.         cout << endl;
  198.         cout << "You deposited Eur " << dp << " to your bank account . . . ";
  199.         cout << endl;
  200.         cout << "Your balance has been updated . . . ";
  201.         cout << endl;
  202.         if (memDp2 == 0){
  203.             lastDeposit2 = balance;
  204.         }
  205.         memDp = 1;
  206.         memDp2 = 1;
  207.         balance -= dp;
  208.         bankMoney += dp;
  209.         system("pause");
  210.         theBank();
  211.     }
  212. }
  213.  
  214. // Loan Function
  215. void loan(void){
  216.     memBank = 1;
  217.     string input;
  218.     balance_balance();
  219.     cout << endl;
  220.     cout << "You chose loan . . . ";
  221.     cout << endl;
  222.     cout << "What do you wish to do?"
  223.     cout << endl;
  224.     cout << "[1] Repay";
  225.     cout << endl;
  226.     cout << "[2] Borrow";
  227.     cout << endl;
  228.     cout << "[3] Check Debt";
  229.     cout << endl;
  230.     cout << "[4] Return";
  231.     cout << endl;
  232.     cout << "Enter Input: Eur ";
  233.     cin >> input;
  234.     if (input == "1"){
  235.         repay();
  236.     }
  237.     else if (input == "2"){
  238.         if (loan1 > 0){
  239.             cout << endl;
  240.             cout << "You already have a loan. Please repay your debt . . . ";
  241.             cout << endl;
  242.             cout << "Debt: Eur " << loan1;
  243.             cout << endl;
  244.             loan();
  245.         }
  246.         else borrow();
  247.     }
  248.     else if (input == "3"){
  249.         checkDebt();
  250.     }
  251.     else if (input == "4"){
  252.         theBank();
  253.     }
  254.     else{
  255.         cout << endl;
  256.         cout << "Invalid input. Please try again.";
  257.         cout << endl;
  258.         system("pause");
  259.         loan();
  260.     }
  261. }
  262.  
  263. // Repay
  264. void repay(){
  265.     balance_balance();
  266.     float repay2 = 0;
  267.     cout << endl;
  268.     cout << "How much money do you want to repay?";
  269.     cout << endl;
  270.     cout << "Enter Input: Eur ";
  271.     cin >> repay2;
  272.     if (loan2 > 0){
  273.         if (repay2 < 0){
  274.             cout << endl;
  275.             cout << "Invalid input. Please try again.";
  276.             cout << endl;
  277.             system("pause");
  278.         }
  279.         else if (repay2 >= loan1){
  280.             cout << endl;
  281.             cout << "You paid the loan too early. " << interest2 << "% repayment penalty.";
  282.             repay2 *= interest2/100;
  283.             loan1 -= repay2;
  284.             loan2 = loan1;
  285.             balance -= repay2
  286.             cout << endl;
  287.         }
  288.     }
  289.     else if (repay2 < 0){
  290.         cout << endl;
  291.         cout << "Invalid input. Please try again.";
  292.         cout << endl;
  293.         system("pause");
  294.         repay();
  295.     }
  296.     else if (repay2 > loan1){
  297.         cout << endl;
  298.         cout << "You cannot repay more than what you owe . . . ";
  299.         cout << endl;
  300.         system("pause");
  301.         repay();
  302.     }
  303.     else if (repay2 <= loan1){
  304.         cout << endl;
  305.         cout << "You have chosen to repay Eur " << loan1 << " by " << repay2 << ".";
  306.         cout << endl;
  307.         loan1 -= repay2;
  308.         balance -= repay2;
  309.         system("pause");
  310.         loan();
  311.     }
  312. }
  313. // Borrow
  314. void borrow(){
  315.     balance_balance();
  316.     float borrow2 = 0;
  317.     cout << endl;
  318.     cout << "How much money do you want to borrow?";
  319.     cout << endl;
  320.     cout << "Enter Input: Eur ";
  321.     cin >> borrow2;
  322.     if (borrow2 < 0){
  323.         cout << endl;
  324.         cout << "Invalid input. Please try again.";
  325.         cout << endl;
  326.         system("pause");
  327.     }
  328.     if (borrow2 <= 1100000){
  329.         //Eur 5000
  330.         if (balance < 5000){
  331.             if (borrow2 > 20000){
  332.                 cout << endl;
  333.                 trust(); cout << "20000."
  334.                 cout << endl;
  335.                 cout << endl;
  336.                 system("pause");
  337.             }
  338.             else{
  339.                 trusted();
  340.             }
  341.         }
  342.         //Eur 10000
  343.         else if (balance < 10000){
  344.             if (borrow2 > 40000){
  345.                 cout << endl;
  346.                 trust(); cout << "40,000.";
  347.                 cout << endl;
  348.             }
  349.             else{
  350.                 trusted();
  351.             }
  352.         }
  353.         else if (balance < 20000){
  354.             if (borrow2 > 120000){
  355.                 cout << endl;
  356.                 trust(); cout << "120,000.";
  357.                 cout << endl;
  358.             }
  359.             else{
  360.                 trusted();
  361.             }
  362.         }
  363.         else if (balance < 120000){
  364.             if (borrow2 > 400000){
  365.                 cout << endl;
  366.                 trust(); cout << "400,000.";
  367.                 cout << endl;
  368.             }
  369.             else{
  370.                 trusted();
  371.             }
  372.         }
  373.         else if (balance < 400000){
  374.             if (borrow2 > 1100000){
  375.                 cout << endl;
  376.                 cout << "Jasper's Bank is only allowed to loan 15% of its legal capital . . . "
  377.                 cout << endl;
  378.                 cout << "Please choose a value that is less than or equal to Eur 1,100,000";
  379.                 cout << endl;
  380.                 borrow();
  381.             }
  382.             else{
  383.                 trusted();
  384.             }
  385.         }
  386.     }
  387. }
  388.  
  389. void compoundBank(void){
  390.     float A, P, r, n, t;
  391.     /*
  392.     A - Final Amount
  393.     P - Initial Principal Balance
  394.     r - Interest Rate
  395.     n - Number of Times Interest Applied per Turn Period
  396.     t - Number of 4-Turns
  397.     1 turn = 4 months
  398.     3 turns = 12 months
  399.     */
  400.     r = interest2;
  401.     t = memLoan%3;
  402.     n = 1;
  403.     P = bankMoney;
  404.     A = P(pow(1 + (r / n)), n * t);
  405.     bankMoney += A;
  406. }
  407.  
  408. void trust(void){
  409.     cout << endl;
  410.     cout << "Jasper's Bank doesn't trust you to repay your loan."
  411.     cout << endl;
  412.     cout << "Please input a value less than or equal to Eur ";
  413. }
  414.  
  415. void trusted(void){
  416.     cout << endl;
  417.     cout << "You borrowed Eur " << borrow2 << " from Jasper's Bank with " << interest << "%.";
  418.     loan1 += borrow2;
  419.     balance += borrow2;
  420.     loan2 = loan1;
  421.     cout << endl;
  422.     system("pause");
  423.     memLoan = 1;
  424.     loan();
  425. }
  426.  
  427. void checkDebt(void){
  428.     cout << endl;
  429.     cout << "Debt: Eur " << loan1;
  430.     cout << endl;
  431.     system("pause");
  432.     if (memBank == 0){
  433.         theBank();
  434.     }
  435.     else if (memBank == 1){
  436.         loan();
  437.     }
  438. }
  439.  
  440. void rules(void){
  441.     cout << endl;
  442.     cout << endl;
  443.     cout << "Rules"
  444.     cout << endl;
  445.     cout << "============================================================================";
  446.     cout << endl;
  447.     cout << "Every turn is equal to four month.";
  448.     cout << endl;
  449.     cout << "Every three turns is equal to one year.";
  450.     cout << endl;
  451.     cout << "Every turn your loan debt increases.";
  452.     cout << endl;
  453.     cout << "If you have not paid in the third turn your debt will be dealt with taxes.";
  454.     cout << endl;
  455.     cout << "There is a penalty for not paying your debt.";
  456.     cout << endl;
  457.     cout << "============================================================================";
  458.     cout << endl;
  459.     cout << endl;
  460. }
  461.  
  462. void reports(void){
  463.     if (memDp == -1){
  464.         cout << endl;
  465.         cout << "You have not deposited any money yet.";
  466.         cout << endl;
  467.     }
  468.     else if (memDp == 0){
  469.         cout << endl;
  470.         cout << endl;
  471.         cout << "********** Financial Report **********";
  472.         cout << endl;
  473.         cout << "********** Jasper's Bank ***********";
  474.         cout << endl;
  475.         cout << "Last Deposit: Eur " << lastDeposit;
  476.         cout << endl;
  477.         cout << "Increased by: " << (lastDeposit1 / lastDeposit) * 100 << "%.";
  478.         cout << endl;
  479.         cout << "********** End of Report **********";
  480.         cout << endl;
  481.     }
  482.     else if (memDp == 1){
  483.         cout << endl;
  484.         cout << endl;
  485.         cout << "********** Financial Report **********";
  486.         cout << endl;
  487.         cout << "********** Jasper's Bank ***********";
  488.         cout << endl;
  489.         cout << "Curent Deposit: Eur " << lastDeposit
  490.         cout << endl;
  491.         cout << "Increased by: " << (lastDeposit1 / lastDeposit) * 100 << "%.";
  492.         cout << endl;
  493.         cout << "********** End of Report **********";
  494.         cout << endl;
  495.     }
  496. }
Add Comment
Please, Sign In to add comment