Answer to Question #282234 in C++ for Hope

Question #282234

AUTOMATED TELLER MACHINE

Create a C++ program that will

  • Deposit cash amount in a bank account
  • Check available balance of the account
  • Withdraw cash amount from an account
  • Compute for the interest earned for balances greater than Php 10,000.00
  • Charges for having a balance below the required minimum

Maintaining balance is Php 5,000.00

Interest rate is 5%

Bank charge is 2%

PIN (Personal Identification Number) is required to do a bank transaction

The program gives the user an option to change PIN





1
Expert's answer
2021-12-23T16:27:42-0500


#include <iostream>

class Cash
{
    double amount;
    int pin = 1234;
    int interest_rate = 5;
    int bank = 2;
public:
    Cash():amount(0.0){}
    Cash(double a): amount(a){}
    void set_cash(double c)
    {
        int p = 0;
        std::cout<<"Enter PIN: ";
        std::cin>>p;
        if(p == this-> pin)
        {
            amount += c;
        }
        else
        {
            std::cout<<"Cash operations are not permitted\n";
        }
        
    }
    void display()
    {
        std::cout<<"Avaliable balance: "<<amount<<std::endl;
    }
    void withdraw()
    {
        int p = 0;
        std::cout<<"Enter PIN: ";
        std::cin>>p;
        if(p == this-> pin)
        {
            amount = 0;
            std::cout<<"Please collect your cash\n";
        }
        else
        {
            std::cout<<"Cash operations are not permitted\n";
        }
    }
    
    void calculate(int year)
    {
        for(int i = 0; i!= year; ++i)
        {
            this->amount+= amount * interest_rate / 100 - bank * interest_rate / 100;
        }
    }
    void change_pin()
    {
        int p = 0;
        std::cout<<"Enter PIN: ";
        std::cin>>p;
        if(p == this-> pin)
        {
            std::cout<<"Please enter new pin: ";
            std::cin>>p;
            this->pin = p;
        }
    }
};
int main()
{
    Cash c;
    c.display();
    c.set_cash(500000);
    c.calculate(6);
    c.display();
    c.change_pin();
   
    
    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