Create a Software Application for XYZ Bank that allows its members to access their bank account information through an “ATM like” interface. The Menu Options should include: checking the account balance, debiting the account and crediting the account, along with an option to exit the program.
Create an Account Class to represent the customers’ bank accounts. Include a data member of type float to represent the account balance. Provide a constructor that receives an initial balance and uses it to initialize the data member.
c. Member function GetBalance() should return the current balance.
Can someone please help me in Creating a console application in C++ that meet the requirements outlined above With comments Lines telling what each line do
#include <iostream>
#include <string>
using namespace std;
class Account {
private: //attribute
float
balance;
public:
//constructor
Account(float balance)
{
//check or
validate balance
if( 0 >=
balance || balance <= 1000)
{
this->balance = balance;
}
else
{
//invalid balance
this->balance = 0;
cout << "the initial balance was invalid"
<< endl;
}
}
//getters
float getBalance() const{
return
balance;
}
void credit(float amount)
{
//increment
amount
balance +=
amount;
}
void debit(float amount)
{
//check amount
exceeded balance
if(balance <
amount)
{
cout << "Debit amount exceeded account
balance" <<endl;
}
else{
//decrement amount
balance -= amount;
}
}
};
int main()
{
//create object
Account alex_acc = Account(900);
//get balance
cout << alex_acc.getBalance()
<<endl;
alex_acc.credit(52.6); //add amount
cout << alex_acc.getBalance() <<endl;//get
balance
alex_acc.debit(1000); //debit amount
cout << alex_acc.getBalance() <<endl;//get
balance
alex_acc.debit(800); //debit amount
cout << alex_acc.getBalance() <<endl;//get
balance
}
--------output-------
900
952.6
Debit amount exceeded account balance
952.6
152.6
Get Answers For Free
Most questions answered within 1 hours.