#include <iostream>
#include <cmath>
#include <iomanip>
#include <string>
using namespace std;
void displaymenu()
{
cout << " \t\tBank Service \t \n ";
cout << " 1.Deposit\n";
cout << " 2.Loan\n";
cout << " 3.Promotion\n";
}
void depositCalculator(double initialDeposit, double annualInterestRate, int numberOfYears)
{
double totalBalance = initialDeposit;
double interestRate = annualInterestRate / 100;
cout << "Year 1: Your balance after depositing and compound interest is " << totalBalance << endl;
for (int year = 2; year <= numberOfYears; ++year)
{
totalBalance *= (1 + interestRate);
totalBalance += initialDeposit; // Deposit additional amount every year
cout << "Year " << year << ": Your balance after depositing and compound interest is " << totalBalance << endl;
}
cout << "Your total balance after " << numberOfYears << " years of depositing and compound interest is : " << totalBalance << endl;
}
void loan()
{
cout << "Selected Loan\n";
double A, B, C, D, E, F, G;
cout << "-loan-" << endl;
cout << "Enter your loan :";
cin >> A;
cout << "Annual interest 12% per years" << endl;
cout << "How many years do you want to complete the installments : ";
cin >> E;
C = 12;
B = C / 100;
D = E * 12;
F = B / 12;
G = (A * pow(F + 1, D) * F) / (pow(F + 1, D) - 1);
cout << "You will need to pay in installments of " << G << " bath per month " << endl;
cout << "Thank you for using the service." << endl;
}
void promotion()
{
cout << "Selected Promotion\n";
int A, Y;
int N = 1;
double Pr1, total1;
cout << "-Promotion-" << endl;
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;
cout << "Enter the deposit amount: " << endl;
cin >> A;
cout << "Enter the number of years for the deposit without withdrawal: " << endl;
cin >> Y;
cout << "Enter the annual interest rate: " << endl;
cin >> Pr1;
// Check if the deposit period is within 6-12 years
if (Y >= 6 && Y <= 12)
{
Pr1 += 2 ; // Increase the interest rate by 2% for each year beyond the 6th year
}
total1 = A * pow((1 + (Pr1 / (N * 100))), (N * Y));
cout << "Your compound interest: " << total1 << endl;
cout << "Thank you for using the service." << endl;
}
int main()
{
string st[20];
int itemcount = 0;
displaymenu();
int yourservice;
string confirm;
do
{
cout << "Choose the service you want ( 1 Or 2 Or 3):";
cin >> yourservice;
switch (yourservice)
{
case 1:
double initialDeposit, annualInterestRate;
int numberOfYears;
cout << "Enter your initial deposit amount: ";
cin >> initialDeposit;
cout << "Enter the annual interest rate (in percentage): ";
cin >> annualInterestRate;
cout << "Enter the number of years: ";
cin >> numberOfYears;
depositCalculator(initialDeposit, annualInterestRate, numberOfYears);
break;
case 2:
loan();
break;
case 3:
promotion();
break;
}
cout << "Press N to Continue program or Press anything to Exit program:";
cin >> confirm;
} while (confirm == "N");
return 0;
}