Write a simple bank transactions program that will do the following:
Deposit
withdraw
inquire
USE FUNCTIONS FOR THIS PLEASE
#include <iostream>
#include <string>
using namespace std;
class Bank
{
double current_amount = 0;
std::string operations = "";
public:
void Deposit(double money, double months, std::string date, double percent = 5.0)
{
current_amount += money;
double percentage = (months / 12 * percent) / 100.0;
current_amount += current_amount * percentage;
operations += std::string("deposit") + '\t' + '\t' + date + '\t' + std::to_string(money) + std::string("amount") + '\t' + std::to_string(months) + std::string("months") + '\t' + std::to_string(percent) + std::string("percents") + '\n';
}
void Withdraw(double amount, std::string date)
{
current_amount -= amount;
operations += std::string("withdraw") + '\t' + date + '\t' + std::to_string(amount) + std::string("amount\n");
}
void Inquire()
{
std::cout<<operations;
std::cout << "Your current amount of money is\t" << current_amount << std::endl;
}
};
int main()
{
Bank b;
b.Deposit(45000.00, 7.0, "25/12/2020");
b.Withdraw(1000.0, "03/01/2021");
b.Inquire();
return 0;
}
Comments
Leave a comment