Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ Design a class bankAccount that defines a bank account as an ADT and impleme

ID: 3586416 • Letter: C

Question

C++

Design a class bankAccount that defines a bank account as an ADT and implements the basic properties of a bank account.

The program will be an interactive, menu-driven program.

a. Each object of the class bankAccount will hold the following information about an account:

account holder’s name

account number

balance

interest rate

The data members MUST be private.

Create an array of the bankAccount class that can hold up to 20 class objects.

b. Include the member functions to perform the various operations on objects of type bankAccount:

Include all appropriate constructors

Include any get and set member functions for member variables.   

For the account number, include a separate static member (integer) in the class to automatically assign and keep track of account numbers. Each customer should have a unique account number updated using the static member.

Add member functions to:

Set bank account data

Make a deposit into an account

Withdraw from an account. Be sure to include balance error checking, i.e., cannot withdraw more than is in the account.

Update balance with interest

Print all customer data

ALL member variables must be private and accessed through member functions. The main client program CANNOT access the variables directly.

c. Have the program provide the following capabilities (by user request):

Through a menu system provide the capability to:

(1) Add a customer. Ensure that the addition of a new customer does not cause an array overflow. The capability of entering the customer name, initial deposit amount and interest should be provided for a new customer.

(2) Print all customer data for all customers

(3) Update customer data as follows:

Request the user account number (you may need to display customer names and numbers for the user to choose) and though a submenu:

(a) Make a deposit for the customer number entered

(b) Make a withdrawal (with error checking) for the customer number entered

(c) Print balance of the customer number entered

(d) Update balance with interest for the customer number entered

(e) Exit the submenu

(4) Exit the program

d. Write the definitions of the member functions of the class bankAccount.

c. Write an interactive program that uses the class bankAccount and tests various operations on the objects of the class bankAccount. Declare an array of 20 components of type bankAccount.

f. Include error checking (invalid menu choices, subtraction errors, etc.)

g. Include menus and submenus indicating all the menu options available for (1) (4) above.

All classes must have a class definition header file (*.h) and a class implementation file (*.cpp). You must have a main program that exercises these classes (*.cpp). You must create a project in Dev C++. You must submit all header files, source files (*.cpp) and the project file (*.dev). Submit a README file that contains: The names of all your files including all the files in the project; how to compile; and how to run.

And this is what I have so far as a rough draft. I am having trouble with the functions and how i want to run the bank menu.

// header file

class bankAccount {

public :

void getdesposit(double value );

void getwithdraw(double value);

void getinterest ();

void printCustomer();

void setData();

void getName();

bankAccount(); // default constructor

bankAccount(double init_Balance); // constructor with parameters

private:

static int acctNum;

string name;

int accountNumber; // set account # to what the static int acctnum is at that time

double balance;

double interest Rate;

};

// bankacc.h the specification file for the class bankacc

#include <iostream>

#include "bankacc.h"

using namespace std;

void bankAccount::setdesposit(double value );

void bankAccount::getwithdraw(double value); // balance error checking, can't withdraw > account

//Function to retrieve money

void bankAccount::getinterest ();

void bankAccount::printCustomer(); //const

// Function to print customer's information

// Postcondition:

void bankAccount::setData();

void bankAccount::getName();

bankAccount::bankAccount () // default constructor

{

string name ="";

int accountNumber =0;

double balance =0;

double interest Rate =0;

}

bankAccount::bankAccount(double init_Balance) // constructor with parameters

{

static int acctNum =789;

string name =" ";

int accountNumber = acctNum;

double balance = 2000.00;

double interest Rate = .025;

}

// filename : Assignment 2

// Nedra Ellis

// Due Date: Oct 11

// Input: customer's information for a bank

// Output: display customer's information once everything has been entered

// This is a program to that will be user friendly and allow customers to input personal bank information

// using a class

#include <iostream>

#include "bankacc.h"

using namespace std;

int main(){

//bankAcct;

bankAcct acct[20]; // array of bankAccount

int option1,option2;

// Main Menu

cout << "Hello welcome to this bank. What can we assist you with today" << endl;

cout << "Select the your options from the following menu" << endl;

cout << "1.) Add customer." << endl;

cout << "2.) Print customer information. " << endl;

cout << "3.) Update information." << endl;

cin << option1;

do {

switch(option1)

{

case 1:

cout << "You have choosen to add a customer. " << endl;

break;

case 2:

cout << "You have choosen to print your information" << endl;

break;

case 3: // Submenu

if (option1 ==3)

{

cout << "You have choosen to update your information." << endl;

cout << "Please enter your account number" << endl;

//while loop to match account number with database {} and add function

cout << "Please from the following options." << endl;

cout << "1.) Make a deposit for the customer number entered" << endl;

cout << "2.) Make a withdrawal. " << endl;

cout << "3.) Update balance." << endl;

cout << "Exit back to main menu. "<< endl;

// call funciton to search for account number & display names and numbers

switch(option2)

{

case 1:

cout << "You have choosen to make a deposit " << endl;

break;

case 2:

cout << "You have choosen to make a withdrawal." << endl;

break;

case 3:

cout << "You have choosen to update balance with interest." << endl;

break;

default:

cout << "You have choosen to exit back to main menu. " << endl;

// figure out a way to exit the submenu

}

}

break;

default

cout << "You have choosen to exit the main menu. " << endl;

// figure out a way to exit the submenu

}

}while();

return 0 ;

}

/* int main(){

bankAcct acct[20];

//menu

1. add new customer // keep track of all customers, ctr

2. print all customer data // write individual print function that will be for each object ... acct[0], acct[1],etc //if you wanted to print all customers you could create a loop ex. for(i=0; i<ctr,i++){acct[i].print(); }

3. modify a customer // submenu, looping constructs

get customer id // (lookup) need to get customer account number, ex. print all customers you have so far and if you wanted customer # 100 loop thru array and match account number entered to the acct number for each array component to get the array index

1. deposit // ex make a deposit for customer, u found array index in list you ahve so far ex. acct[index].deposit(double value), then how much do you want to desposity and then get value and pass in value into that acct[index].deposit(double value)//

2. withdraw

3. print balance

4. update balance with interest

9. exit sub menu

// she would just create one without the array */

Any help will do and thank you

Explanation / Answer

BANK ACCOUNT

# include<iostream>

class Bank {

int acno;

char name[30];

char account_type[10];

float balance;

public:

Bank()

{

acno = Null;

balance = Null;

}

void start();

void deposit();

void withdraw();

void display_accdetails();

};

void bank :: start()

{

cout<<"Enter required details ";

cout<<"Depositor name : ";

cin.get(name);

cout<<"Enter the Account Number : ";

cin>>accno;

cout<<"Enter the Account Type :-";

cin>>account_type;

cout<<"Deposit Amount: ";

cin >>balance;

}

void bank :: deposit()

{

float extra_amount;

cout <<"Depositing";

cout<<"Enter the amount to deposit : ";

cin>>extra_amount;

balance+=balance+extra_amount;

}

void bank :: withdraw()

{

float amount;

cout<<"Withdrwal the amount whtever you needed";

cout<<"Enter the amount to withdraw : ";

cin>>amount;

balance-=balance-amount;

}

void bank :: display_accdetails()

{

cout<<" display Account Details";

cout<<" Name of the depositor is : "<<name;

cout<<" Account Number is : "<<accno;

cout<<" Account Type is : "<<account_type;

cout<<" Balance is : "<<balance;

}

int main()

{bank ab;

int choice =1;

while (choice != 0 )

{

cout<<"Enter 5 to exit"

<<" 1. Create account."<<" 2. Deposit money"<<" 3.Withdraw money"<<" 4.See Account Status";

cin>>choice;

switch(choice)

{

case 1 : ab.start();

break;

case 2: ab.deposit();

break;

case 3 : ab.withdraw();

break;

case 4: ab.display_accdetails();

break;

case 5 :ab.Exit

break;

default: cout<<" Match Not Found";

}

}

return 0;

}