AUTOMATED TELLER MACHINE
Create a C++ program that will
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
#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;
}
Comments
Leave a comment