Code Needs Some Guidance

Hello, I need some help with my code. I know it's all over the place but I am wondering why it is not working. Please help me as soon as you can thank you.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
 //
//  main.cpp
//  Bank Account
//
//  Created by user on 9/19/18.
//  Copyright © 2018 user. All rights reserved.
//

#include <iostream>
#include <string>
#include "BankAccountHeader.h"
#include "savingsAccountH.h"
#include "checkingAccountH.h"
#include <iomanip>
#include <fstream>

using namespace std;

int mainMenu();
void insideMenuSav(int, savingsAccount members[]);
void insideMenuCheck(int, checkingAccount members[]);

int getAccountNumber();

void getMemberData(ifstream& infile, savingsAccount saccounts[], checkingAccount caccounts[]);


int main() {
    
    
    ifstream inFile;

    savingsAccount members2[10];
    checkingAccount members3[10];
    
    char c;
    
    
    getMemberData(inFile, members2, members3);
    
    
    
    
    
    cout <<"Are you a savings account, or a checking account? Type \"c\" for checking and \"s\" for savings.";
    
    cin >> c;
    
    c = char(tolower(c));
    if(c == 'c'){
        insideMenuCheck(getAccountNumber(),members3);
    }
    
    if(c == 's'){
        insideMenuSav(getAccountNumber(),members2);
    }
    
    
    
    return 0;
}


void getMemberData(ifstream& infile, savingsAccount saccounts[], checkingAccount caccounts[]) {
    
    string firstName;
    string lastName;
    string AccountType;
    string accountBalance;
    string trash;
    int count;
    
    infile.open("members.txt");
    

    
    for(count = 0; count < 10; count++){
        int k = -1;
        int b = -1;
        
        infile >> firstName;
        infile >> lastName;
        infile >> AccountType;
        infile >> accountBalance;
        infile >> trash;
        
        if(AccountType == "s"){
            saccounts[k+1].setFirstName(firstName);
            saccounts[k+1].setLastName(lastName);
            saccounts[k+1].setAccountType("Savings");
            saccounts[k+1].setAccountBalance(stod(accountBalance));
            saccounts[k+1].setAccountNumberDefault();
            saccounts[k+1].setAccountNumber();
            k++;
        }
        
        if(AccountType == "c"){
            caccounts[b+1].setFirstName(firstName);
            caccounts[b+1].setLastName(lastName);
            caccounts[b+1].setAccountType("Checking");
            caccounts[b+1].setAccountBalance(stod(accountBalance));
            caccounts[b+1].setAccountNumberDefault();
            caccounts[b+1].setAccountNumber();
            b++;
        }
        
    } // END FOR LOOP
    
    
} //END GET MEMBER FUNCTION

    
int mainMenu () {
    int response;
    
    cout << endl;
    cout << "_________________________________________________" << endl;
    cout << setw(17) << left << "1. View your account" << endl;
    cout << setw(17) << left << "2. Deposit/withdraw money." << endl;
    cout << setw(17) << left << "3. View transactions history." << endl;
    cout << setw(17) << left << "4. Exit." << endl;
    cout << "_________________________________________________"<<endl <<endl;
    
    
    cout << "Please enter a number and press enter." ;
    cin >> response;
    cout << endl;
    
    if (response >4 || response == 0){
        cout << "Please enter a correct menu item 1-5.";
        cin>> response;
    }
    
    return response;
}

 

Last edited on
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
void insideMenuSav (int accountNumber, savingsAccount members[]) {

    int response;
    char response2;
    char response4;
    
    
    response = mainMenu();
    
    if(response == 1) {
        members[accountNumber%100].printAccount();
        
        cout << endl;
        
        cout <<"Back to main menu? Type \"y\" and press enter for yes. Type any other character for no.";
        
        cin >> response2;
        
        response2 = char(tolower(response2));
        
        if(response2 == 'y'){
            insideMenuSav(accountNumber, members);
                            }
        else {
            cout <<"Goodbye." << endl;
            cout << "Sign in?: Type \"y\" and press enter for yes. Type any other character for no.";
            cin >> response2;
            
            response2 = char(tolower(response2));
            cout << endl;
            
            if(response2 == 'y'){
                insideMenuSav(getAccountNumber(), members);
                                }
            else {
                cout <<"Thank you and have a nice day." <<endl <<endl;
                }
            
            }
        
        
    } //END SWITCH RESPONSE 1
    
    else if (response == 2)
    {
        cout << "Would you like to withdraw or deposit? Type \"w\" for withdraw and \"d\" for deposit.";
        cin >> response2;
        
        response2 = char(tolower(response2));
        
        if(response2 == 'w'){
            members[accountNumber%100].withdraw();
        }
        
        else if(response2 == 'd'){
            members[accountNumber%100].deposit();
        }
        
        cout <<"Back to main menu? Type \"y\" and press enter for yes. Type any other character for no.";
        
        cin >> response2;
        
        response2 = char(tolower(response2));
        
        if(response2 == 'y'){
            insideMenuSav(accountNumber, members);
        }
        else if (response != 'y'){
            cout <<"Goodbye." << endl;
            cout << "Sign in?: Type \"y\" and press enter for yes. Type any other character for no.";
            cin >> response2;
            
            response2 = char(tolower(response2));
            
            cout << endl;
            
            if(response2 == 'y'){
                insideMenuSav(getAccountNumber(), members);
            }
            else {
                cout <<"Thank you and have a nice day." <<endl <<endl;
            }
            
        }
        
    } //END SWITCH RESPONSE 2
    
    else if(response == 3) {
        
        cout << fixed << setprecision(2);
        
        members[accountNumber%100].printTransHistory();
        
        cout << endl;
        
        cout <<"Back to main menu? Type \"y\" and press enter for yes. Type any other character for no.";
        
        cin >> response2;
        
        response2 = char(tolower(response2));
        
        if(response2 == 'y'){
            insideMenuSav(accountNumber, members);
        }
        else if (response != 'y'){
            cout <<"Goodbye." << endl;
            cout << "Sign in?: Type \"y\" and press enter for yes. Type any other character for no.";
            cin >> response2;
            response2 = char(tolower(response2));
            cout << endl;
            
            if(response2 == 'y'){
                insideMenuSav(getAccountNumber(), members);
            }
            else {
                cout <<"Thank you and have a nice day." <<endl <<endl;
            }
            
        }
       
        
    } // END SWITCH RESPONSE 3

    
    else if(response == 4){
        cout << "You are now signed out.";
        cout <<"Sign in? Type \"y\" and press enter for yes. Type any other character for no.";
        
        cin >>response2;
        
        response2 = char(tolower(response2));
        
        if(response2 == 'y'){
            insideMenuSav(getAccountNumber(), members);
        }
        else {
            cout <<"Thank you and have a nice day.";
        }
        
        
        
    } //END SWITCH RESPONSE 4
    
    
}// END insideMENU FUNCTION

Last edited on
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
//BEGIN INSIDEMENU2

void insideMenuCheck (int accountNumber, checkingAccount members[]) {
    
    int response;
    char response2;
    char response4;
    
    
    response = mainMenu();
    
    if(response == 1) {
        members[accountNumber%100].printAccount();
        
        cout << endl;
        
        cout <<"Back to main menu? Type \"y\" and press enter for yes. Type any other character for no.";
        
        cin >> response2;
        
        response2 = char(tolower(response2));
        
        if(response2 == 'y'){
            insideMenuCheck(accountNumber, members);
        }
        else {
            cout <<"Goodbye." << endl;
            cout << "Sign in?: Type \"y\" and press enter for yes. Type any other character for no.";
            cin >> response2;
            
            response2 = char(tolower(response2));
            cout << endl;
            
            if(response2 == 'y'){
                insideMenuCheck(getAccountNumber(), members);
            }
            else {
                cout <<"Thank you and have a nice day." <<endl <<endl;
            }
            
        }
        
        
    } //END SWITCH RESPONSE 1
    
    else if (response == 2)
    {
        cout << "Would you like to withdraw or deposit? Type \"w\" for withdraw and \"d\" for deposit.";
        cin >> response2;
        
        response2 = char(tolower(response2));
        
        if(response2 == 'w'){
            members[accountNumber%100].withdraw();
        }
        
        else if(response2 == 'd'){
            members[accountNumber%100].deposit();
        }
        
        cout <<"Back to main menu? Type \"y\" and press enter for yes. Type any other character for no.";
        
        cin >> response2;
        
        response2 = char(tolower(response2));
        
        if(response2 == 'y'){
            insideMenuCheck(accountNumber, members);
        }
        else if (response != 'y'){
            cout <<"Goodbye." << endl;
            cout << "Sign in?: Type \"y\" and press enter for yes. Type any other character for no.";
            cin >> response2;
            
            response2 = char(tolower(response2));
            
            cout << endl;
            
            if(response2 == 'y'){
                insideMenuCheck(getAccountNumber(), members);
            }
            else {
                cout <<"Thank you and have a nice day." <<endl <<endl;
            }
            
        }
        
    } //END SWITCH RESPONSE 2
    
    else if(response == 3) {
        
        cout << fixed << setprecision(2);
        
        members[accountNumber%100].printTransHistory();
        
        cout << endl;
        
        cout <<"Back to main menu? Type \"y\" and press enter for yes. Type any other character for no.";
        
        cin >> response2;
        
        response2 = char(tolower(response2));
        
        if(response2 == 'y'){
            insideMenuCheck(accountNumber, members);
        }
        else if (response != 'y'){
            cout <<"Goodbye." << endl;
            cout << "Sign in?: Type \"y\" and press enter for yes. Type any other character for no.";
            cin >> response2;
            response2 = char(tolower(response2));
            cout << endl;
            
            if(response2 == 'y'){
                insideMenuCheck(getAccountNumber(), members);
            }
            else {
                cout <<"Thank you and have a nice day." <<endl <<endl;
            }
            
        }
        
        
    } // END SWITCH RESPONSE 3
    
    
    else if(response == 4){
        cout << "You are now signed out.";
        cout <<"Sign in? Type \"y\" and press enter for yes. Type any other character for no.";
        
        cin >>response2;
        
        response2 = char(tolower(response2));
        
        if(response2 == 'y'){
            insideMenuCheck(getAccountNumber(), members);
        }
        else {
            cout <<"Thank you and have a nice day.";
        }
        
        
        
    } //END SWITCH RESPONSE 4
    
    
}// END insideMENUCheck FUNCTION


int getAccountNumber() {
    int accountNumber;
    cout << "Please enter your account number to sign on: " << endl << endl;
    cin >> accountNumber;
    
    return accountNumber;
    
}

        
        


THIS IS MY MAIN CODE^^.

[/code]
Last edited on
These are my other files in my code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//
//  checkingAccountH.h
//  Bank Account
//
//  Created by user on 10/14/18.
//  Copyright © 2018 user. All rights reserved.
//

#include "BankAccountHeader.h"
#include <iostream>

#ifndef checkingAccountH_h
#define checkingAccountH_h

class checkingAccount : public bankAccount {
    static int accountNumberDefault;
    double intR;
    double servicecharge;
    
public:
    checkingAccount();
    
    void withdraw();
    void deposit();
    
    void setInterestRate();
    void setServiceCharges();
    double getAccountBalance2() const;
    double getInterestRate() const;
    int getServiceCharges() const;
    void printAccount() const;
    
    
    void setAccountNumber();
    void setAccountNumberDefault();
    
    
    
};




#endif /* checkingAccountH_h */


Thisv
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
//
//  impChecking.cpp
//  Bank Account
//
//  Created by user on 10/14/18.
//  Copyright © 2018 user. All rights reserved.
//
#include "BankAccountHeader.h"
#include "checkingAccountH.h"
#include <stdio.h>
#include <string>
#include <iostream>
#include <cstdlib>
#include <iomanip>


int checkingAccount :: accountNumberDefault = 199;


checkingAccount :: checkingAccount(){
    intR = 0.0;
    servicecharge = 0.0;
    accountType = "Savings";
}



double checkingAccount:: getAccountBalance2() const
{
    return accountBalance;
}

double checkingAccount:: getInterestRate() const {
    
    return intR;
    
}
int checkingAccount:: getServiceCharges() const {
    
    return servicecharge;
}

void checkingAccount:: setServiceCharges() {
    
    if(accountBalance < 500) {
        servicecharge = 10;
    }
    
    accountBalance -= 10;
    
    
}


// PRINT ACCOUUNT
//
void checkingAccount::  printAccount() const {
    
    cout << "Name: " << fName << " " << lName << endl;
    cout << "Account type: " << accountType << endl;
    cout << "Account number: " << accountNumber << endl;;
    
    cout << fixed << setprecision(2);
    
    cout << "Current Balance: " << "$" << accountBalance <<endl;;
    
    cout << endl;
    
    
}
//
//


void checkingAccount :: setInterestRate(){
    
    
    if (getAccountBalance() >= 0 && getAccountBalance() <5000 ){
        
        intR = .01;
    }
    
    if (getAccountBalance() >= 5000 && getAccountBalance() <10000 ){
        
        intR = .01;
    }
    
    else if (getAccountBalance() >= 10000 && getAccountBalance() <25000 ){
        
        intR = .02;
    }
    
    else if (getAccountBalance() >= 25000 && getAccountBalance() <50000 ){
        
        intR = .03;
    }
    else if(getAccountBalance() >= 50000 && getAccountBalance() < 250000){
        
        intR = .04;
        
    }
    else if(getAccountBalance() >= 250000 && getAccountBalance() < 1000000){
        
        intR =.06;
    }
    
    else if(getAccountBalance() >= 1000000 && getAccountBalance() < 10000000000000000){
        intR = .10;
    }
}


// WITHDRAW FUNCTION
//
void checkingAccount:: withdraw() {
    
        
        cout << fixed << setprecision(2);
        
        cout << "How much would you like to withdraw? ";
        cin >> withdrawal;
        
        accountBalance -= withdrawal;
        
        if( accountBalance < 0){
            
            cout <<"There will be a $25 insufficient funds fee. " << endl << endl ;
            accountBalance -= 25.00;
        }
        
        cout << "Your new account balance is: " << accountBalance <<endl <<endl;
        
        setInterestRate();
        
        toString = to_string(withdrawal);
        toString.erase (toString.find_last_not_of('0') + 3, std::string::npos );
        
        transHistory += "Withdrawal: $" + toString + "\n";
        
    
    
}
//
// END WITHDRAW FUNCTION

//DEPOSIT FUNCTION
//
void checkingAccount:: deposit() {
    
    cout << fixed << setprecision(2);
    
    cout << "How much would you like to deposit? ";
    cin >> deposit1;
    cout << endl << endl;
    
    accountBalance += deposit1;
    
    cout << "Your new account balance is: " << accountBalance << endl << endl;
    
    
        setInterestRate();
    
    
    toString = to_string(deposit1);
    toString.erase (toString.find_last_not_of('0') + 3, string::npos );
    
    transHistory += "Deposit: $" + toString + "\n";
} // END DEPOSIT


// SET ACCOUNT NUMBERS
//
void checkingAccount :: setAccountNumberDefault() {
    accountNumberDefault++;
}
void checkingAccount:: setAccountNumber() {
    accountNumber = accountNumberDefault;
}
//
// 


And thisv

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//
//  savingsAccountH.h
//  Bank Account
//
//  Created by user on 10/14/18.
//  Copyright © 2018 user. All rights reserved.
//

#include "BankAccountHeader.h"
#include <iostream>

#ifndef savingsAccountH_h
#define savingsAccountH_h
class savingsAccount  : public bankAccount {

private:
static int accountNumberDefault;
double intR;
double servicecharge;
    
public:
    savingsAccount();
    void setInterestRate();
    void setServiceCharges();
    double getAccountBalance2() const;
    double getInterestRate() const;
    double getServiceCharges() const;
    void printAccount() const;
    
    void withdraw();
    void deposit();
    
    void setAccountNumberDefault();
    void setAccountNumber();
    
};
#endif /* savingsAccountH_h */ 


And thisv

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206

//
//  impSavings.cpp
//  Bank Account
//
//  Created by user on 10/14/18.
//  Copyright © 2018 user. All rights reserved.
//

#include "BankAccountHeader.h"
#include "savingsAccountH.h"
#include <stdio.h>
#include <iostream>
#include <iomanip>




/*
 savingsAccount();
 void setInterestRate();
 void setServiceCharges();
 double getAccountBalance2() const;
 double getInterestRate() const;
 int getServiceCharges() const;
 void printAccount() const;
 */



int savingsAccount::accountNumberDefault = 299;

//CONSTRUCTOR
//
savingsAccount::savingsAccount(){
    intR = 0.0;
    servicecharge = 0.0;
}
//
//






//SET INTEREST RATE
//
void savingsAccount:: setInterestRate(){
    
    
    if (getAccountBalance() >= 0 && getAccountBalance() <5000 ){
        
        intR = .01;
    }
    
    if (getAccountBalance() >= 5000 && getAccountBalance() <10000 ){
        
        intR = .02;
    }
    
    else if (getAccountBalance() >= 10000 && getAccountBalance() <25000 ){
        
        intR = .03;
    }
    
    else if (getAccountBalance() >= 25000 && getAccountBalance() <50000 ){
        
        intR = .04;
    }
    else if(getAccountBalance() >= 50000 && getAccountBalance() < 250000){
        
        intR = .07;
        
    }
    else if(getAccountBalance() >= 250000 && getAccountBalance() < 1000000){
        
        intR =.09;
    }
    
    else if(getAccountBalance() >= 1000000 && getAccountBalance() < 10000000000000000){
        intR = .15;
    }
    
    
} //END SET INTR

//
//

//SET SERVICE CHARGES

void savingsAccount:: setServiceCharges() {
    
    if(accountBalance < 500) {
        servicecharge = 10;
    }
    accountBalance -= 10;
}

//
//


double savingsAccount :: getAccountBalance2() const {
    return accountBalance;
    
}

double savingsAccount :: getInterestRate() const {
    return intR;

}

double savingsAccount :: getServiceCharges() const{
    return servicecharge;
};


// PRINT ACCOUUNT
//
void savingsAccount ::  printAccount() const {
    
    cout << "Name: " << fName << " " << lName << endl;
    cout << "Account type: " << accountType << endl;
    cout << "Account number: " << accountNumber << endl;;
    
    cout << fixed << setprecision(2);
    
    cout << "Current Balance: " << "$" << accountBalance <<endl;;
    
    cout << endl;
    
}
//
//


// WITHDRAW FUNCTION
//
void savingsAccount:: withdraw() {
    
    
    cout << fixed << setprecision(2);
    
    cout << "How much would you like to withdraw? ";
    cin >> withdrawal;
    
    accountBalance -= withdrawal;
    
    if( accountBalance < 0){
        
        cout <<"There will be a $25 insufficient funds fee. " << endl << endl ;
        accountBalance -= 25.00;
    }
    
    cout << "Your new account balance is: " << accountBalance <<endl <<endl;
    
    setInterestRate();
    
    toString = to_string(withdrawal);
    toString.erase (toString.find_last_not_of('0') + 3, std::string::npos );
    
    transHistory += "Withdrawal: $" + toString + "\n";
    
    
    
}
//
// END WITHDRAW FUNCTION

//DEPOSIT FUNCTION
//
void savingsAccount:: deposit() {
    
    cout << fixed << setprecision(2);
    
    cout << "How much would you like to deposit? ";
    cin >> deposit1;
    cout << endl << endl;
    
    accountBalance += deposit1;
    
    cout << "Your new account balance is: " << accountBalance << endl << endl;
    
    
    setInterestRate();
    
    
    toString = to_string(deposit1);
    toString.erase (toString.find_last_not_of('0') + 3, string::npos );
    
    transHistory += "Deposit: $" + toString + "\n";
} // END DEPOSIT

// SET ACCOUNT NUMBERS
//
void savingsAccount :: setAccountNumberDefault() {
    accountNumberDefault++;
}
void savingsAccount:: setAccountNumber() {
    accountNumber = accountNumberDefault;
}
//
//


And this is my parent class and imp filesvv

//
// Bank Account Header.h
// Bank Account
//
// Created by user on 9/21/18.
// Copyright © 2018 user. All rights reserved.
//
#include <string>
#include <iostream>


using namespace std;

#ifndef BankAccountHeader_h
#define BankAccountHeader_h

class bankAccount {
protected:
static int accountNumberDefault;

string fName;
string lName;
int accountNumber;
string accountType;
double accountBalance;


char cORs;
double withdrawal;
double deposit1;
string transHistory;
string toString;





public:

bankAccount();
//Default constructor


void setAccountBalance(double);


void setNewAccount(string&, string&, int&, string&, double&);
void setChangeAccount(string&, int&, string&, double&, double&);


void setAccountType(string);
void setFirstName(string);
void setLastName(string);




int getAccountNumber() const;
double getAccountBalance() const;

string getAccountType() const;

//OLD FUNCTION:
// void newAccount();

//OTHER FUNCTIONS:
void printAccount() const;
void withdraw();
void deposit();
void printTransHistory() const;

};

#endif /* BankAccountHeaderh */

[/code]

This is the implementation file for the parent class:



Last edited on
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
#include "BankAccountHeader.h"
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <iomanip>

using namespace std;




//CONSTRUCTOR
//
bankAccount::bankAccount(){
    fName = "";
    lName = "";
    accountNumber = 0;
    accountType = "";
    accountBalance =0.0;
}
//
//

//SETTERS
//
void bankAccount:: setAccountType(string s) {
    if(s == "c"){
       accountType = "Checking";
    }
    else if(s == "s"){
        accountType = "Savings";
    }
}

//SET FIRST NAME
//

void bankAccount:: setFirstName(string k) {
    fName = k;
}

void bankAccount:: setLastName(string k) {
    lName = k;
}





//GETTERS
//
int bankAccount :: getAccountNumber() const {
    return accountNumber;
}
double bankAccount:: getAccountBalance() const{
    return accountBalance;
}

string bankAccount:: getAccountType() const {
    return accountType;
}
//
//




//PARAMETERS SET ACCOUNT
//
void bankAccount :: setNewAccount(string& fNam, string& lNam, int& accountNum, string& type, double& balance){
    
    fName = fNam;
    lName = lNam;
    accountNumber = accountNum;
    accountType = type;
    accountBalance = balance;
    
}
//
//

void bankAccount :: setAccountBalance(double s) {
    accountBalance = s;
}


// PRINT ACCOUUNT
//
void bankAccount :: printAccount() const {
    
    cout << "Name: " << fName << " " << lName << endl;
    cout << "Account type: " << accountType << endl;
    cout << "Account number: " << accountNumber << endl;;
    
    cout << fixed << setprecision(2);
    
    cout << "Current Balance: " << "$" << accountBalance <<endl;;
    
    cout << endl;
    
    
}
//
//



//OPEN NEW ACCOUNT
//
/*
void bankAccount :: newAccount() {
    
    cout << "Thank you for choosing Prosper! Please fill out our form and press enter after every input entered." << endl << endl;
    
    //first and last name
    cout << "What is your first name? ";
    cin >> fName;
    cout << endl;
    cout << "What is your last name? ";
    cin >> lName;
    cout << endl << endl;
    
    //account type
    cout << "What kind of account are you signing up for? Type \"c\" for checking and \"s\" for savings.";
    cin >> cORs;
    cout << endl << endl;
    
    
    cORs = char(tolower(cORs));
    
    if(cORs == 'c'){
        
        accountType = "Checking";
        
        cout << "How much are you depositing? Minimum amount is $25.00 : " << endl;
        cin >> accountBalance;
        
    }//end if
    
    if(cORs == 's'){
        
        accountType = "Savings";
        cout << "How much are you depositing? Minimum amount is $25.00 : " << endl;
        cin >> accountBalance;
        
    
    }
    
    
    
    //account number
    setAccountNumberDefault();
    setAccountNumber();
    
    cout << "Your private account number is: " << accountNumber << "." << endl << endl <<endl;

    
    
} // END OPEN NEW ACCOUNT FUNCTION

//
//
 */

//WITHDRAW AND DEPOSIT
//

void bankAccount:: withdraw() {
    
    cout << fixed << setprecision(2);
    
    cout << "How much would you like to withdraw? ";
    cin >> withdrawal;
    
    accountBalance -= withdrawal;
    
    if( accountBalance < 0){
        
        cout <<"There will be a $25 insufficient funds fee. " << endl << endl ;
        accountBalance -= 25.00;
    }
    
    cout << "Your new account balance is: " << accountBalance <<endl <<endl;
    
    
    toString = to_string(withdrawal);
    toString.erase (toString.find_last_not_of('0') + 3, std::string::npos );
    
     transHistory += "Withdrawal: $" + toString + "\n";
    
    
} //END WITHDRAW

void bankAccount:: deposit() {
    
    cout << fixed << setprecision(2);
    
    cout << "How much would you like to deposit? ";
    cin >> deposit1;
    cout << endl << endl;
    
    accountBalance += deposit1;
    
    cout << "Your new account balance is: " << accountBalance << endl << endl;
    
    
    toString = to_string(deposit1);
    toString.erase (toString.find_last_not_of('0') + 3, string::npos );
    
    transHistory += "Deposit: $" + toString + "\n";
} // END DEPOSIT

//
//


//PRINT TRANSHISTORY
//
void bankAccount:: printTransHistory() const {
    cout << transHistory;
    
    
}
//
//





I reused my old code so there's a lot of things that are confusing me in this new code. If you could please help me out, that would be great, thank you.
What does "not working" mean?

What are the "things that are confusing" you.

We're not mind-readers. If you have problems that you want help solving, you need to tell us what those problems are.

Be as complete as possible, as precise as possible, and as specific as possible.
Also please post a sample of your input file.

Your code also seems to have a lot of code duplication, you may want to start by trying to eliminate most of the duplication.

Topic archived. No new replies allowed.