Question: Where am I going wrong? Define a bankAccount class that implements some basic properties of a bank account. An object of this class should store

Where am I going wrong?

Define a bankAccount class that implements some basic properties of a bank account. An object of this class should store the following data: Account holder's name (string), account number (int), balance (double), account type (string, checking/saving) and interest rate (double). Store interest rate as a decimal number. Add appropriate member functions to manipulate the object. Use a static member in the class to automatically assign account numbers. Also declare an array of 12 components of type bankAccount to process up to 12 customers and write a program to illustrate how to use your class.

#include

using namespace std;

//Define a bankAccount class that implements some basic properties of a bank account.

class bankAccount {

public:

//Add appropriate member functions to manipulate the object.

void setHolder(string fn = "", string ln = "");

void setAccountType(string chck, string save);

void setAccountNum(int num);

void setBalance(double amount);

void setInterest(double rate);

string getHolder() const;

string getAccountType() const;

int getAccountNum() const;

double getBalance() const;

//Store interest rate as a decimal number

double getInterest() const;

void print() const;

private:

string firstName;

string lastName;

string checking;

string saving;

static int account;

double balance;

double newBalance;

double interest;

};

//Main Function

#include

#include

#include

#include "bankAccount.h"

using namespace std;

void bankAccount::setHolder(string fn, string ln) {

cout << "Enter your first name: ";

cin >> fn;

cout << " Enter your last name: ";

cin >> ln;

firstName = fn;

lastName = ln;

}

string bankAccount::getHolder() const {

return firstName, lastName;

}

void bankAccount::setAccountType(string chck, string save) {

char temp;

cout << "Checking/Saving" << "Enter 'c' for checking or 's' for saving: " << endl;

cin >> temp;

switch(temp){

case 'c':

checking = chck;

interest = 0.0;

break;

case 's':

saving = save;

interest = 1.2;

break;

}

}

string bankAccount::getAccountType() const {

return checking, saving;

}

void bankAccount::setAccountNum(int num){

for (int i = 0; i <= 9; i++)

num += rand() % 10;

account = num;

}

void bankAccount::setBalance(double amount) {

int temp;

cout << "How much would you like to deposit? " << endl;

cin >> amount;

balance = amount;

temp = balance * interest;

newBalance = balance + temp;

}

double bankAccount::getBalance() const {

return balance;

return newBalance;

}

int bankAccount::getAccountNum() const {

return account;

}

void bankAccount::setInterest(double rate) {

interest = rate;

}

double bankAccount::getInterest() const {

return interest;

}

void bankAccount::print() const {

cout << "Member: " << lastName << ", " << firstName << " Account Type: " << checking, saving;

cout << " - " << account << "$" << balance << " Interest Rate: " << interest << endl;

cout << "projected balance after 12 months: " << newBalance;

}

int main() {

cout << "Welcome to a Wicked Credit Union. Lets set up a new account." << endl;

//array of 12 components

bankAccount newMember[12];

newMember->print();

cout << endl << endl;

system("\pause");

return 0;

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!