Answer to Question #260341 in C++ for Kyutiiii

Question #260341

Write a simple bank transactions program that will do the following:


Deposit


withdraw


inquire



USE FUNCTIONS FOR THIS PLEASE

1
Expert's answer
2021-11-02T14:43:14-0400
#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;
   
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS