In: Computer Science
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.
Can someone please help me in Creating a console application in C++ that meet the requirements outlined above. With comments Lines
Full C++ Program for the given problem statement is as follows:
#include<iostream>
using namespace std;
class Account{
public:
float balance;
Account(){
cout<<"\nEnter the initial balance : ";
cin>>balance;
if (balance<1000){
balance = 0.0;
cout<<"\nInitial balance was invalid ";
}
else
cout<<"Account Created";
}
void Debit(){
float debit;
cout<<"\nEnter the amount to be debited : ";
cin>>debit;
if (debit>balance)
{
cout<<"\nDebit amount exceeded account balance.";
}
else{
balance=balance-debit;
cout<<"\n Remaining Account balance : "<<balance;
}
}
void Credit(){
float credit;
cout<<"\nEnter the amount to be credited : ";
cin>>credit;
balance=balance+credit;
cout<<"Current Balance : "<<balance;
}
void GetBalance(){
cout<<"Current Balance : $"<<balance;
}
};
int main(){
Account person;
int i;
while (1){
cout<<"\nAccount Operations ";
cout<<"\n-------------------";
cout<<"\n1. Credit Balance \n2. Debit Balance \n3. Show Balance \n4. Exit";
cout<<"\n--------------------\nEnter your choice : ";
cin>>i;
switch(i){
case 1: person.Credit();
break;
case 2: person.Debit();
break;
case 3: person.GetBalance();
break;
case 4: exit(0);
}
}
return 0;
}
Output:
I hope you find this solution helpful.
Keep Learning!