fork download
  1. #include <iostream>
  2. #include <cmath>
  3. #include <iomanip>
  4. #include <string>
  5. using namespace std;
  6.  
  7. void displaymenu()
  8. {
  9. cout << " \t\tBank Service \t \n ";
  10. cout << " 1.Deposit\n";
  11. cout << " 2.Loan\n";
  12. cout << " 3.Promotion\n";
  13. }
  14.  
  15. void depositCalculator(double initialDeposit, double annualInterestRate, int numberOfYears)
  16. {
  17. double totalBalance = initialDeposit;
  18. double interestRate = annualInterestRate / 100;
  19.  
  20. cout << "Year 1: Your balance after depositing and compound interest is " << totalBalance << endl;
  21.  
  22. for (int year = 2; year <= numberOfYears; ++year)
  23. {
  24. totalBalance *= (1 + interestRate);
  25. totalBalance += initialDeposit; // Deposit additional amount every year
  26. cout << "Year " << year << ": Your balance after depositing and compound interest is " << totalBalance << endl;
  27. }
  28.  
  29. cout << "Your total balance after " << numberOfYears << " years of depositing and compound interest is : " << totalBalance << endl;
  30. }
  31.  
  32. void loan()
  33. {
  34. cout << "Selected Loan\n";
  35. double A, B, C, D, E, F, G;
  36. cout << "-loan-" << endl;
  37. cout << "Enter your loan :";
  38. cin >> A;
  39. cout << "Annual interest 12% per years" << endl;
  40. cout << "How many years do you want to complete the installments : ";
  41. cin >> E;
  42. C = 12;
  43. B = C / 100;
  44. D = E * 12;
  45. F = B / 12;
  46. G = (A * pow(F + 1, D) * F) / (pow(F + 1, D) - 1);
  47. cout << "You will need to pay in installments of " << G << " bath per month " << endl;
  48. cout << "Thank you for using the service." << endl;
  49. }
  50.  
  51. void promotion()
  52. {
  53. cout << "Selected Promotion\n";
  54. int A, Y;
  55. int N = 1;
  56. double Pr1, total1;
  57. cout << "-Promotion-" << endl;
  58. cout << "If deposited for more than 6 years but not more than 12 years, the bank will provide an additional 2% interest per year." << endl;
  59. cout << "Enter the deposit amount: " << endl;
  60. cin >> A;
  61. cout << "Enter the number of years for the deposit without withdrawal: " << endl;
  62. cin >> Y;
  63. cout << "Enter the annual interest rate: " << endl;
  64. cin >> Pr1;
  65.  
  66. // Check if the deposit period is within 6-12 years
  67. if (Y >= 6 && Y <= 12)
  68. {
  69. Pr1 += 2 ; // Increase the interest rate by 2% for each year beyond the 6th year
  70. }
  71.  
  72. total1 = A * pow((1 + (Pr1 / (N * 100))), (N * Y));
  73. cout << "Your compound interest: " << total1 << endl;
  74. cout << "Thank you for using the service." << endl;
  75. }
  76.  
  77. int main()
  78. {
  79.  
  80. string st[20];
  81. int itemcount = 0;
  82.  
  83. displaymenu();
  84. int yourservice;
  85. string confirm;
  86. do
  87. {
  88. cout << "Choose the service you want ( 1 Or 2 Or 3):";
  89. cin >> yourservice;
  90. switch (yourservice)
  91. {
  92. case 1:
  93. double initialDeposit, annualInterestRate;
  94. int numberOfYears;
  95.  
  96. cout << "Enter your initial deposit amount: ";
  97. cin >> initialDeposit;
  98.  
  99. cout << "Enter the annual interest rate (in percentage): ";
  100. cin >> annualInterestRate;
  101.  
  102. cout << "Enter the number of years: ";
  103. cin >> numberOfYears;
  104.  
  105. depositCalculator(initialDeposit, annualInterestRate, numberOfYears);
  106. break;
  107. case 2:
  108. loan();
  109. break;
  110. case 3:
  111. promotion();
  112. break;
  113. }
  114. cout << "Press N to Continue program or Press anything to Exit program:";
  115. cin >> confirm;
  116. } while (confirm == "N");
  117.  
  118. return 0;
  119. }
  120.  
Success #stdin #stdout 0s 5292KB
stdin
Standard input is empty
stdout
 		Bank Service 	 
  1.Deposit
  2.Loan
  3.Promotion
Choose the service you want ( 1 Or 2 Or 3):Press N to Continue program or Press anything to Exit program: