Please code in C++ NOTE: Minimum requirement to qualify for grading: 1) Code mus
ID: 3708472 • Letter: P
Question
Please code in C++
NOTE: Minimum requirement to qualify for grading: 1) Code must be properly indented, modularized and follows the best practices.
Account Project (A bank account has methods to deposit, withdraw, and check the balance.) (100 points)
1. The program contains 3 main variables called accountBalance, accountName and accountNum. Choose appropriate data types for these variables
2. initializes the accountName with the parameter specified. The member variables accountBalance and accountNum are assigned some random value (No need to use rand function).
3. The program will contain member functions named menu, withdraw, and deposit
The withdraw function checks to see if balance is sufficient for withdrawal. If so, decrements balance by amount; if not, prints an appropriate message indicating insufficient funds and displays the current balance.
The deposit function adds deposit amount to balance and displays new balance
The menu function will contain the following menu options: 1. Check Balance, 2. Deposit Amount, 3. Withdraw Amount, 4. Exit. Use appropriate messages for each option selected and then call the correct function to perform the task.
Output:
Welcome to the Bank Account program
Here is your Initial Account Information:
Account for: Helen
Account #: 123456
Balance: $187.5
************************
Menu
************************
1. Check Balance
2. Deposit Amount
3. Withdraw Amount
4. Exit
Please make a selection: 8
ERROR: Invalid choice. Please try again !!!
************************
Menu
************************
1. Check Balance
2. Deposit Amount
3. Withdraw Amount
4. Exit
Please make a selection: 1
Here is the account Information:
Account for: Helen
Account #: 123456
Balance: $187.5
************************
Menu
************************
1. Check Balance
2. Deposit Amount
3. Withdraw Amount
4. Exit
Please make a selection: 2
Enter the amount you want to deposit: 50
Depositing $50 to Acc# 123456
Your new balance is now $237.5
Explanation / Answer
#include <iostream>
#include <string>
using namespace std;
class Account{
private:
string firstname;
string lastname;
string FullName;
int accountnumber;
double balance;
public:
Account(){
firstname = "Raaj";
lastname = "Lokanathan";
FullName = "Raaj Lokanathan";
accountnumber = 5671;
balance = 0.0;
}
Account(string fName,string lName,int accno,double bal);
void setFullName(string fullname);
void setaccountnumber(int accno);
void setbalance(double bal);
void setwithdraw(int wdraw);
void setdeposit(int dep);
string getFullName();
int getaccountnumber();
double getbalance();
void display();
};
Account::Account(string fName,string lName,int accno,double bal){
firstname = fName;
lastname = lName;
accountnumber = accno;
balance = bal;
}
void Account::setFullName(string fullname){
FullName = fullname;
}
void Account::setaccountnumber(int accno){
accountnumber = accno;
}
void Account::setbalance(double bal){
balance = bal;
}
void Account::setwithdraw(int wdraw){
wdraw=balance-wdraw;
}
void Account::setdeposit(int dep){
dep=dep+balance;
}
string Account::getFullName(){
return FullName;
}
int Account::getaccountnumber(){
return accountnumber;
}
double Account::getbalance(){
return balance;
}
void Account::display(){
cout<<"First Name: "<<firstname<<endl;
cout<<"Last Name: "<<lastname<<endl;
cout<<"Account Number: "<<accountnumber<<endl;
cout<<"Current Balance: "<<balance<<endl;
}
int main(){
Account Acc;
Acc.setFullName("Raaj Lokanathan");
Acc.setaccountnumber(5671);
Acc.setbalance(0.0);
Acc.display();
Account acc[50];
string full_name;
int acc_no;
double bAl;
int i;
for(i=0;i<50;i++){
cout<<"Please enter the details for the customer: "<<i+1<<endl;
cout<<"Please enter your full name: ";
getline(cin,full_name);
cout<<"Please enter your account number: ";
cin>>acc_no;
cout<<"Please enter your current balance: ";
cin>>bAl;
acc[i].setFullName(full_name);
acc[i].setaccountnumber(acc_no);
acc[i].setbalance(bAl);
}
for(i=0;i<50;i++){
cout<<"Detail for the bank customers"<<i+1<<endl;
acc[i].display();
}
system("pause");
return 0;
}