This code must be in C++ The following pictures are the format for parts of the
ID: 3861784 • Letter: T
Question
This code must be in C++
The following pictures are the format for parts of the code:
In this project, we will make up a banking system. You are an employee of MadeUp Banking Your job is to manage multiple bank accounts. Here, you would create new accounts, deposit to an account, withdraw from an account, delete account, sort the accounts, or do inspection on one or all bank accounts. In order to do this job, you would need the tool for each of those items. The bank maintains a list of accounts. This list has to be available as long as the bank is in business Write a program in C++ to run the MadeUp Banking business. As state above, the list of account has to be available as long as you run the program. This means the list of the account has to be initialized in the main() function. Write a function for each of the items above. You will call these functions to perform any task on the bank accounts. Each account will have account number, name (last, first), and balance. The header file, function file, and main file are as the sample below. Al functions are of type void. You will fill in the necessary function parameters In order to do this project, you would need to understand pointers, functions, and vectors among other basic C++ knowledge. You will follow the exact requirement and format of the program. Any unnecessary changes will result in points taken offExplanation / Answer
Header File:-
#ifndef HEADER_H_H_INCLUDED
#define HEADER_H_H_INCLUDED
#include<iostream>
#include<string>
#include<vector>
using namespace std;
class account
{
public:
string acno; //a/c number- taken as string in case the a/c no is alpha-numeric
string lastname;
string firstname;
double balance;
bool operator<(const account &rhs) const { return acno < rhs.acno; } //overloading the '<' operator for std::sort
};
void menu(int* num); //display the menu
void makeAccount(vector<account>& bank); //create a new account
void printAccount(vector<account>& bank);//show account details
void printAllAccount(vector<account>& bank); //display all accounts
void depositAccount(vector<account>& bank);// deposit money into account
void withdrawAccount(vector<account>& bank);//withdraw money from account
void deleteAccount(vector<account>& bank); //delete an account
void sortAccount(vector<account>& bank); //sort all accounts by account no.
#endif // HEADER_H_H_INCLUDED
This is in the function.cpp file:-
#include "header_h.h"
#include<vector>
using namespace std;
void menu(int *num)
{
int select =0;
cout<<"Welcome to Made Up Banking. Select options below:"<<endl;
cout<<" 1. Make new account"<<" 2. Display all accounts."
<<" 3. Deposit to an account."<<" 4. Withdraw from an account."
<<" 5. Print account."<<" 6. Delete an account."
<<" 7. Quit."<<endl;
cout<<"Selection : ";
cin>>select;
*num=select;
}
void makeAccount(vector<account>& bank)
{
account temp;
cout<<"Enter Account No : ";
cin>>temp.acno;
cout<<"Enter First Name : ";
cin>>temp.firstname;
cout<<"Enter Last Name : ";
cin>>temp.lastname;
cout<<"Enter The amount deposited : ";
cin>>temp.balance;
bank.push_back(temp);
}
void printAccount(vector<account>& bank)
{
string accnum;
cout<<"Enter the A/c No :";
cin>>accnum;
vector<account>::iterator i;
for(i=bank.begin();i!=bank.end() && (*i).acno!=accnum;i++);
if((*i).acno==accnum)
{
cout<<"Account Details of A/c No "<<accnum<<":-"<<endl;
cout<<"First Name: "<<(*i).firstname<<endl;
cout<<"Last Name: "<<(*i).lastname<<endl;
cout<<"Balance: "<<(*i).balance<<endl;
}
else
cout<<"Invalid Account Number."<<endl;
}
void printAllAccount(vector<account>& bank)
{
vector<account>::iterator i;
cout<<"List of all Account Details :- ";
for(i=bank.begin();i!=bank.end();i++)
{
cout<<"Account No: "<<(*i).acno<<endl;
cout<<"First Name: "<<(*i).firstname<<endl;
cout<<"Last Name: "<<(*i).lastname<<endl;
cout<<"Balance: "<<(*i).balance<<endl<<endl;
}
}
void depositAccount(vector<account>& bank)
{
string accnum;
cout<<"Enter the A/c No :";
cin>>accnum;
vector<account>::iterator i;
for(i=bank.begin();i!=bank.end() && (*i).acno!=accnum;i++);
if((*i).acno==accnum)
{
double amt;
cout<<"Enter the Amount to be deposited : ";
cin>>amt;
(*i).balance+=amt;
cout<<"New Balance: "<<(*i).balance<<endl;
}
else
cout<<"Invalid Account Number."<<endl;
}
void withdrawAccount(vector<account>& bank)
{
string accnum;
cout<<"Enter the A/c No :";
cin>>accnum;
vector<account>::iterator i;
for(i=bank.begin();i!=bank.end() && (*i).acno!=accnum;i++);
if((*i).acno==accnum)
{
double amt;
cout<<"Enter the Amount to be withdrawn : ";
cin>>amt;
if(amt<=((*i).balance))
{
(*i).balance-=amt;
cout<<"New Balance: "<<(*i).balance<<endl;
}
else
{
cout<<"Insufficient Balance.";
cout<<"Balance: "<<(*i).balance<<endl;
}
}
else
cout<<"Invalid Account Number."<<endl;
}
void deleteAccount(vector<account>& bank)
{
string accnum;
cout<<"Enter the A/c No :";
cin>>accnum;
vector<account>::iterator i;
for(i=bank.begin();i!=bank.end() && (*i).acno!=accnum;i++);
if((*i).acno==accnum)
{
bank.erase(i);
cout<<"Account Deleted "<<accnum<<endl;
}
else
cout<<"Invalid Account Number."<<endl;
}
void sortAccount(vector<account>& bank)
{
std::sort(bank.begin(),bank.end());
}
And the main.cpp file:-
#include "header_h.h"
#include<vector>
#include<conio.h>
using namespace std;
int main()
{
//declare a vector of account objects called bank
vector<account> bank;
int input=0;
int *inputPtr=&input;
menu(inputPtr);
while(input!=7)
{
switch(input)
{
case 1 : makeAccount(bank);
cout<<"Press Any Key to continue..."<<endl;
getch();
break;
case 2 : printAllAccount(bank);
cout<<"Press Any Key to continue..."<<endl;
getch();
break;
case 3: depositAccount(bank);
cout<<"Press Any Key to continue..."<<endl;
getch();
break;
case 4: withdrawAccount(bank);
cout<<"Press Any Key to continue..."<<endl;
getch();
break;
case 5 : printAccount(bank);
cout<<"Press Any Key to continue..."<<endl;
getch();
break;
case 6: deleteAccount(bank);
cout<<"Press Any Key to continue..."<<endl;
getch();
break;
case 7 : return 0; //this case should never be reached
default : cout<<"Invalid Entry. Please enter a choice number (1,2,..7) from the above menu"<<endl;
}
menu(inputPtr); //display the menu again
}
return 0;
}