Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Administration The Complete Guide To Dba Practices And Procedures

Authors: Craig S. Mullins

2nd Edition

0321822943, 978-0321822949

More Books

Students also viewed these Databases questions

Question

How wide are Salary Structure Ranges?

Answered: 1 week ago