Answer to Question #284091 in C++ for Liv

Question #284091

In (Question #282822 in C++ for qq_576) can you please also add these?


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

The interest rate is 5%

Bank charge is 2%


Thank you!!!


1
Expert's answer
2022-01-02T08:17:04-0500
#include<iostream>
#include<string>


using namespace std;


class ATM
{
	double amount;
	string PIN;
public:
	ATM(double _amount, string _PIN):amount(_amount),PIN(_PIN){}
	bool checkPIN()
	{
		string _PIN;
		cout << "Please, enter your PIN: ";
		cin >> _PIN;
		if (_PIN == PIN)
			return true;
		else
			return false;
	}
	void DeposCash()
	{
		if (checkPIN())
		{
			cout << "\nPlease, enter a cash: ";
			cin >> amount;
		}
		else
			cout << "Incorrect PIN!";
	}
	void ShowBalance()
	{
		if (checkPIN())
		{
			cout << "\nYour balance: " << amount;
		}
		else
			cout << "Incorrect PIN!";
	}
	void Withdraw()
	{
		if (checkPIN())
		{
			int withdr;
			cout << "\nPlease, enter a cash to withdraw: ";
			cin>> withdr;
			if (withdr < 0)
				return;
			else
			{
				amount -= withdr;
			}
		}
		else
			cout << "Incorrect PIN!";
	}
	void ForTheInterest()
	{
		if (checkPIN())
		{
			double perc = 0;
			if (amount > 10000)
			{
				perc = (amount - 10000)*0.05;
			}
			cout << "\nYour interest for balance is " << perc;
		}
		else
			cout << "Incorrect PIN!";
	}
	void ChargesForBal()
	{
		if (checkPIN())
		{
			double perc = 0;
			if (amount < 5000)
			{
				perc = amount *0.02;
			}
			cout << "\nYour charges are " << perc;
		}
		else
			cout << "Incorrect PIN!\n";
	}
	void ChangePIN()
	{
		if (checkPIN())
		{
			string _PIN;
			cout << "Please, enter your new PIN: ";
			cin >> _PIN;
			PIN = _PIN;
			cout << "\nYou changed PIN on " << PIN;
		}
		else
			cout << "Incorrect PIN!\n";
	}
};




void Menu()
{
	cout << "\n******AUTOMATED TALLER MACHINE******\n";
	cout << "1 - Deposit cash amount in a bank account\n"
		<< "2 - Check available balance of the account\n"
		<< "3 - Withdraw cash amount from an account\n"
		<< "4 - Compute for the interest earned for balances\n"
		<< "5 - Charges for having a balance\n"
		<< "6 - Change PIN\n"
		<< "0 - Exit prohgram\n"
		<< "Your choice: ";
}


int main()
{
	ATM atm(0,"0000");
	string pin;
	cout << "******AUTOMATED TALLER MACHINE******\n";
	cout << "Please, enter a PIN (0000- default): ";
	cin >> pin;
	if (pin != "0000")
	{
		cout << "Incorrect PIN!\n";
		return -1;
	}	
	int choice;
	do
	{
		Menu();
		cin >> choice;
		switch (choice)
		{
		case 0: break;
		case 1:
			{
				atm.DeposCash();
				break;
			}
		case 2:
			{
				atm.ShowBalance();
				break;
			}
		case 3:
			{
				atm.Withdraw();
				break;
			}
		case 4:
			{
				atm.ForTheInterest();
				break;
			}
		case 5:
			{
				atm.ChargesForBal();
				break;
			}
		case 6:
			{
				atm.ChangePIN();
				break;
			}
		}
	} while (choice != 0);


	cin>>choice;


	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