Please assist or show me how to finish one of the .cpp files in a Banking program with header files

Pages: 12
Problem Description:
This program covers the above concepts with an example that is dealing with bank transactions. Generally a person can have an account like checking or savings, and/or both in any bank. This example particularly deals with deposit and withdraw amount in saving or checking account. The transaction will be successful only if the following 2 conditions are met:

i)Entered account number should match with account type(checking or savings). Separate account number for checking and savings account.

ii)Entered account number details should be in the bankData.csv file.

When you exit/quit the program, two separate data files (saving_account.csv and checking_account.csv) will be generated with the updated information of the accounts specifically withdraw and deposit. This program will not change the bankData.csv after the transactions.

Supplied:
The main.cpp program is provided as the driver for the assignment. Please do not change the main.cpp program. This assignment has several header files(bankAcoount.h, checkingAccount.h, savingsAccount.h, fileoperation.h). All the header files need not to be changed/modified. This assignment will give an opportunity to excel in multiple file implementation. In this assignment, you will write the implementation file for each header file. To compile you need all the cpp files along with main.cpp file.

Interface files(Header files): bankAcoount.h; checkingAccount.h; savingsAccount.h; fileoperation.h
Implementation files (cpp files): BankAccountImp.cpp; checkingAccountImp.cpp;
savingsAccountImp.cpp; fileoperationImp.cpp
Main cpp file: bankmain.cpp

Coding the assignment:
A skeleton code has been provided for you to use.
• bankAcoount.h,
• checkingAccount.h
• savingsAccount.h
• fileoperation.h
• bankmain.cpp
Note: No changes required for above bankmain.cpp and header files.
You will code the following files:
• BankAccountImp.cpp
• checkingAccountImp.cpp
• savingsAccountImp.cpp
• fileoperationImp.cpp

Detailed Function Descriptions:
Every bank offers the accounts like checking, savings. The class checkingAccount and savingAccount are derived (public) from the class bankAccount. This class inherits members to store the account number and the balance from the base class. In this assignment, a customer with a checking account can deposit money and withdraw money. With the withdraw option, make sure that the customer can not draw more than the amount in his/her account. A customer with savings account will have the same operations as checking account. However, a customer with a savings account typically receives interest, makes deposits, and withdraws money. The interest rate will be calculated for every 1, 2 and 3 year and should display the final amount for each year.

The class Fileclass is an other base class that deals with file input/output operations. This class has a constructor and destructor. In FileClass() , saving_account.csv and checking_account.csv files are created and open those files every time you compile the program. Also it has the logic to prompt a message to enter the filename and if the file is not open, then it should re-prompt to enter the file name.In ~FileClass() destructor, you should close all the files – bankData.csv, saving_account.csv and checking_account.csv.

Function Descriptions:
The following are more detailed descriptions of the required functions:

class bankAccount is a base class. bankAccount.h is provided- Do not make any changes
In bankAccountImp.cpp file:

Write the definition of the member functions set so that protected members are set according to the parameters. The values of the int and double instance variables must be non-negative.

Functions:
void setAccountNumber(int acct); void setAddress(string address);
void setAccountType(string accType); void setCity(string city);
void setFirstName(string firstName); void setPhone1(long int phone1);
void setLastName(string lastName); void setPhone2(long int phone2);
void setCompanyName(string companyName); void setBalance(int balance);
Write the definition of the member functions get to return the values of the instance variable.
Functions:
int getAccountNumber() const; string getAddress() const;
string getAccountType() const; string getCity() const;
string getFirstName() const; long int getPhone1() const;
string getLastName() const; long int getPhone2() const;
string getCompanyName() const; double getBalance() const;

void withdraw(double amount);- This function should subtract the amount from the balance and update the balance.
void deposit(double amount); - This function should add the amount from the balance and update the balance.

-----------------------------------------
bankMain.cpp file:
-----------------------------------------
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
#include <iostream>
#include <iomanip>
#include <sstream>
#include <string>
#include <vector>

#include "bankAccount.h"
#include "savingsAccount.h"
#include "checkingAccount.h"
#include "fileOperation.h"

using namespace std;

int main()
{
    int count = 0;
    vector<checkingAccount> Caccounts;
    vector<savingsAccount> Saccounts;
    FileClass fd;
    char input;
   

    if(fd.fileError == true)
    {
        return -1;
    }

    readFile(fd.inFile, Caccounts, Saccounts, count);
    // fileobj.readFile(fd.inFile, Caccounts, Saccounts, count);


    do
    {
        cout << "Main Menu\n";
        cout << "Please make your selection\n";
        cout << "D - Deposit money\n";
        cout << "W - Withdraw money\n";
        cout << "Q - Quit\n";
        cout << "Selection: " << endl;;
        cin >> input;


        switch (input)
        {
        case 'd':
        case 'D':
            processMoney(Caccounts, Saccounts, true, false);
        // fileobj.processMoney(Caccounts, Saccounts, true, false);
            
            break;
        case 'w':
        case 'W':
            processMoney(Caccounts, Saccounts, false, true);
        // fileobj.processMoney(Caccounts, Saccounts, false, true);
            break;
        case 'q':
        case 'Q':
            writeFile(fd.outSavingFile, fd.outCheckingFile, Caccounts, Saccounts, count);
        // fileobj.writeFile(fd.outSavingFile, fd.outCheckingFile, Caccounts, Saccounts, count);
            cout << "Goodbye!"<<endl;
            break;
        default:

            cout << "Main Menu\n";
            cout << "Please make your selection\n";
            cout << "D - Deposit money\n";
            cout << "W - Withdraw money\n";
            cout << "Q - Quit\n";
            cout << "\nSelection: " << endl;
            cin >> input;
            
            break;

        }
    } while (input != 'q' && input != 'Q');

    return 0;
}


--------------------------
bankAccount.h header file:
--------------------------
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
//Class bankAccount
#ifndef H_bankAccount 
#define H_bankAccount
/**
 * @brief bankAccount
 * 
 */
class bankAccount
{
public:
    void setAccountNumber(int acct);
    void setAccountType(string accType);
    void setFirstName(string firstName);
    void setLastName(string lastName);
    void setCompanyName(string companyName);
    void setAddress(string address);
    void setCity(string city);
    void setPhone1(long int phone1);
    void setPhone2(long int phone2);
    void setBalance(int balance);
    
    int getAccountNumber() const;
    string getAccountType() const;
    string getFirstName() const;
    string getLastName() const;
    string getCompanyName() const;
    string getAddress() const;
    string getCity() const;
    long int getPhone1() const; 
    long int getPhone2() const; 
    double getBalance() const; 


    void withdraw(double amount);
    void deposit(double amount);
    // void print() const;

protected:
    int accountNumber;
    double balance;   
    string accountType;
    string firstName;
    string lastName;
    string companyName;
    string address;
    string city;
    long int phone1;
    long int phone2;
};

#endif 

Last edited on
bankAccountImp.cpp file:
------------------------
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
#include <iostream>
#include <cstring>
#include <string>
#include "bankAccount.h"

using namespace std;

void bankAccount::setAccountNumber(int acc)
{
  if (acc < 0)
    cerr << "Invalid account number" << endl;
  else
    this->accountNumber = acc;
}

void bankAccount::setBalance(double bal)
{
  if(bal < 0)
    cerr << "Invalid balance" << endl;
  else
    this->balance = bal;
}

void bankAccount::setAccountType(string input)
{
  this->accountType = input;
}

void bankAccount::setFirstName(string input)
{
  this->firstName = input;
}

void bankAccount::setLastName(string input)
{
  this->firstName = input;
}

void bankAccount::setCompanyName(string input)
{
  this->companyName = input;
}

void bankAccount::setAddress(string input)
{
  this->address = input;
}

void bankAccount::setCity(string input)
{
  this->city = input;
}

void bankAccount::setPhone1(long int input)
{
  if (input <0)
    cerr << "Invalid Phone Number" << endl;
  else
    this->phone1 = input;
}

void bankAccount::setPhone2(long int input)
{
  if (input < 0)
    cerr << "Invalid Phone Number" << endl;
  else
    this->phone2 = input;
}

int bankAccount::getAccountNumber() const
{
  return this->accountNumber;
}

double bankAccount::getBalance() const
{
  return this-> balance;
}

string bankAccount::getFirstName() const
{
  return this->firstName;
}

string bankAccount::getLastName() const
{
  return this->lastName;
}

string bankAccount::getCompanyName() const
{
  return this->companyName;
}

string bankAccount::getAddress() const
{
  return this->address;
}

string bankAccount::getCity() const
{
  return this->city;
}

long int bankAccount::getPhone1() const
{
  return this->phone1;
}

long int bankAccount::getPhone2() const
{
  return this->phone2;
}

void bankAccount::withdraw(double amount)
{
  if(amount < 0)
    cerr << "Invalid Amount" << endl;
  else
    this->balance += amount;
}


----------------------------------------------
class checkingAccount is a derived class from base class bankAccount and is inherited as public. It has2 functions.
public:
void withdraw(double amount);
void print() const;

checkingAccount.h is provided- Do not make any changes
In checkingAcountImp.cpp file:

void withdraw(double amount); - This function should check, if the requested withdraw amount is less than or equal to the balance and if it is above then display a message !! Not enough money in the checking account !!; else update the balance after withdrawal amount.
void print() const; - This function should outputs the values of instance variables like AccountType, AccountNumber, FirstName, LastName, Balance. You no need print all the instance variables. (Hint: Use getters)

------------------------------
checkingAccount.h header file:
------------------------------
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
//Class checkingAccount 
  
#ifndef H_checkingAccount
#define H_checkingAccount
 
#include "bankAccount.h"

/**
 * @brief checkAccount is a derived class from bankAccount base class and is inherited as public
 * 
 */
class checkingAccount: public bankAccount 
{
public:
    void withdraw(double amount);  // // update balance after withdrawal; balance=balance-withdraw;
    void print() const; /*This function should outputs the values of instance variables like AccountType, AccountNumber, FirstName, 
    						LastName, Balance. You no need print all the above instance variables. (Hint: Use getters */      
};

#endif 

----------------------------
checkingAccountImp.cpp file:
----------------------------
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include "checkingAccount.h"
#include <iostream>

using namespace std;

void checkingAccount::withdraw(double amount)
{
  if(amount < 0)
    cerr << "Invalid Amount" << endl;
  else if (amount > this->balance)
    cerr << "!! Not enough money in checking account !!" << endl;
  else
    this->balance -= amount;
}

void checkingAccount::print()
{
  cout << "Account Type:" << this->getAccountType() << endl;
  cout << "Account Number: " << this->getAccountNumber() << endl;
  cout << "First Name: " << this->getFirstName() << endl;
  cout << "Last Name: " << this->getLastName() << endl;
  cout << "Balance: " << this->getBalance() << endl;
}

-------------------------------------------
class savingsAccount is a derived class from base class bankAccount and is inherited as public. It has 2 functions.
public:
void withdraw(double amount);
void print() const;
protected:
double interestRate;

savingsAccount.h is provided- Do not make any changes

In savingsAcountImp.cpp file:
void withdraw(double amount); - Similar to withdraw function in checkingAccountImp.cpp
void print() const; - Similar to print function in checkingAccountImp.cpp; In addition to them, you have to print "Interest you can earn after 1 Year, 2 Year, and 3 Year in a separate line." The interest rate
is calculated as follows:
Interest you can earn after 1 Year: balance*interestRate*1)/100;
Interest you can earn after 2 Year: balance*interestRate*2)/100
Interest you can earn after 3 Year: balance*interestRate*3)/100
savingsAccount(double intRate = DEFAULT_INTEREST_RATE_SAVINGS); // Constructor with a parameter having a default value – Write the definition of this constructor with the instance variable interestRate(protected member)

-----------------------------
savingsAccount.h header file:
-----------------------------

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
//Class savingsAccount 

#ifndef H_savingsAccount
#define H_savingsAccount
   
#include "bankAccount.h"

const double DEFAULT_INTEREST_RATE_SAVINGS = 2.5;

/**
 * @brief savingsAccount is a derived class from base class bankAccount and is inherited as public
 * 
 */
class savingsAccount: public bankAccount
{ 
public:
    void withdraw(double amount); // update balance after withdrawal; balance=balance-withdraw;
    void print() const; /*This function should outputs the values of instance variables like AccountType, AccountNumber, FirstName, 
    						LastName, Balance. Interest you can earn after 1 Year, 2 Year, and 3 Year in a separate line.
    						You no need print all the above instance variables. (Hint: Use getters */
    savingsAccount(double intRate = DEFAULT_INTEREST_RATE_SAVINGS); /*Constructor with a parameter having a default value – 
    															Write the definition of this constructor with the instance variable 
    															interestRate(protected member)*/

protected:
    double interestRate;
};

#endif 


---------------------------
savingsAccountImp.cpp file:
---------------------------
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
#include "savingsAccount.h"
#include <iostream>

using namespace std;

savingsAccount::savingsAccount(double intRate)
{
  this->interestRate = intRate;
}

void savingsAccount::withdraw(double amount)
{
  if (amount < 0)
    cerr << "Invalid Amount" << endl;
  else if (amount > this->balance)
    cerr << "!! Not enough money in checking account !!" << endl;
  else
    this->balance -= amount;
}

void savingsAccount::print()
{
  cout << "Account Type: " << this->getAccountType() << endl;
  cout << "Account Number: " << this->getAccountNumber() << endl;
  cout << "First Name: " << this->getFirstName() << endl;
  cout << "Last Name: " << this->getLastName() << endl;
  cout << "Balance: " << this->getBalance() << endl;

  for (int i = 1; i < 4; ++i)
    cout << "Interest you can earn after " << i << " Year:" << this->balance * this->interestRate * i / 100.0 << endl;
}


Last edited on
class FileClass is another base class that deals with file input/output operations. This class has a constructor, destructor and other functions.
In FileClass(), saving_account.csv and checking_account.csv files are created every time you compile the program. Open those files in the constructor. Also it should have the logic to prompt a message to enter the filename and if the file is not open, then it should re-prompt to enter the file name.

In ~FileClass() destructor, you should close all the files – bankData.csv, saving_account.csv and checking_account.csv.

Write the definitions of the following functions in fileOperationImp.cpp:


1: string makeStringUpper(string s)-
string s – the string to be converted to upper case.
return value – upper case version of passed string.
This function converts the passed string to upper case and returns it. The library function toupper() may be called by this function.


2: void readFile(ifstream &inFile, vector<checkingAccount> &Caccount, vector<savingsAccount> &Saccount, int &count); (before transaction)
ifstream &inFile - input file stream variable for the file to be opened
vector<checkingAccount> &Caccount - vector type is used to read all fields of checking account data
vector<savingsAccount> &Saccount - vector type is used to read all fields of saving account data
int &count – This count is the number of accounts in the bankData.csv


3: bool openInputFile(ifstream &inFile)
ifstream& infile – file stream variable for the file to be opened


4: bool getNextField(string &line, int &index, string &subString)
string &line– the line of data read from the file that needs to be parsed
int &index– the current starting position of the parsing. The first time this function is called for a new line, index should be set to zero. The function should update the index before returning, so that on the next call it will look at the next field.
string &subString – the parsed string
return value– true if more data is available, false if the whole string has been parsed.


5: void saveFieldSavingAccount(int fieldNumber, string subString, savingsAccount &tempItem)
int fieldNumber – the number of the field, starting at zero
string subString– the value to be saved in the field, may require conversion to double inside the function.
savingsAccount &tempItem- the record(savings account) to which the field will be added


6: void saveFieldCheckingAccount(int fieldNumber, string subString, checkingAccount &tempItem)
int fieldNumber – the number of the field, starting at zero
string subString– the value to be saved in the field, may require conversion to double inside the function.
savingsAccount &tempItem- the record(savings account) to which the field will be added


7: double stringConvertDouble(string s) - This function is used to convert account balance
string s– the string to be converted into a double
return value– the double converted from the string
This function converts a string to it’s corresponding double value. Implementation of the function must use string stream. All other implementations are not allowed and will have significant point deductions.


8: long int stringConvertInt(string s); This function is used to convert account number, phone 1 and 2
string s– the string to be converted into int
return value– the double converted from the string


9: int processMoney(vector<checkingAccount> &Caccount, vector<savingsAccount> &Saccount,
bool deposit_f, bool withdraw_f);
- Initially, prompt a message to enter the account Checking or Saving
- use makeStringUpper for the entered account and compare. If the account does not match with
SAVING or CHECKING, then output an error message “Error : Entered Account type wrong,
Account type should be saving or checking”
- prompt a message to enter the account number
- Read the entered number as a string
- if deposit_f=true, then display a message “Enter the Deposit Amount”
- if withdraw_f=true, then display a message “Enter Withdraw Amount”
-Read the entered amount as a string
- if accountType is SAVING, then use stringConvertDouble(string s) to convert entered amount to
double and stringConvertInt(string s) to convert entered account number to int
- Loop through the database vector, if the account number matches with any saving account number
in database, then display a message “**Account Information before transaction **”
- Use print() for saving account- use getters for accountType, accountNumber, firstName,
lastName, balance, balance()*interestRate*1/100 for Year 1, balance()*interestRate*2/100 for Year
2, balance()*interestRate*3/100 for Year 3
- if deposit_f=true, then update the balance using the function deposit(amount)
- if withdraw_f=true, then update the balance using the function withdraw(amount)
- Display a message “**Account Information after transaction **”
-Again use print() to check the updated balance and other functions as above print()
-if the account number is not found in the database, then display a message “Error: Given Account
number not present in Saving Account Type”
- else if ,accountType is Checking, then repeat the steps as continued for SAVINGS account above.

and last function:

10: void writeFile(ofstream &savingFile, ofstream &checkingFile, vector<checkingAccount> &Caccount, vector<savingsAccount> &Saccount, int &count); (after transaction)
fileoperation.h header file:
-----------------------------

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
//Class FileClass 

#ifndef H_fileInfo
#define H_fileInfo

#include <iostream>
#include <iomanip>
#include <fstream>

#include "savingsAccount.h"
#include "checkingAccount.h"


using namespace std;

/**
 * @brief FileClass is a separate base class and deals with file INput/Output data- Constructors opens input file, savings output file, checkings output file 
 * 
 */
class FileClass
{

public:
    ifstream inFile;
    ofstream outSavingFile;
    ofstream outCheckingFile;
    bool fileError;

    /**
     * @brief Construct a new File Class:: File Class object
     * 
     */
    FileClass()
    {
        char file_name[100];
        char saving_file[] = "saving_account.csv";
        char checking_file[] = "checking_account.csv";
        
        fileError = false;
        
        cout << "Enter input File Name: " << endl;
        cin >> file_name;

        inFile.open(file_name, ios::in);

        while(inFile.fail()){
            inFile.clear();
            inFile.ignore(100, '\n');
            cout << "###########################################################" << endl;
            cout << "Error : Input file not present : " << file_name << endl;
            cout << "###########################################################" << endl;
            cout << "Enter input File Name: " << endl;
            cin >> file_name;
            inFile.open(file_name, ios::in);
        }
        

        outSavingFile.open(saving_file, ios::out);
        if (!outSavingFile.good())
        {
            fileError = true;
            cout << "Error : outSavingFile file not opening : " << saving_file << endl;
        }

        outCheckingFile.open(checking_file, ios::out);
        if (!outCheckingFile.good())
        {
            fileError = true;
            cout << "Error : outCheckingFile file not opening : " << checking_file << endl;
        }    
    }
    /**
     * @brief Destroy the File Class:: File Class object
     * 
     */
    ~FileClass()
    {
        inFile.close();
        outSavingFile.close();
        outCheckingFile.close();
    }

};

    //check documentation for each function description

    string makeStringUpper(string s);
    void readFile(ifstream &inFile, vector<checkingAccount> &Caccount, vector<savingsAccount> &Saccount, int &count);
    void writeFile(ofstream &savingFile, ofstream &checkingFile, vector<checkingAccount> &Caccount, vector<savingsAccount> &Saccount, int &count);
    bool openInputFile(ifstream &inFile);
    bool getNextField(string &line, int &index, string &subString);
    void saveFieldSavingAccount(int fieldNumber, string subString, savingsAccount &tempItem);
    void saveFieldCheckingAccount(int fieldNumber, string subString, checkingAccount &tempItem);
    double stringConvertDouble(string s);
    long int stringConvertInt(string s);
    int processMoney(vector<checkingAccount> &Caccount, vector<savingsAccount> &Saccount, bool deposit_f, bool withdraw_f);



#endif  
Last edited on
see post below for correct fileOperationImp.cpp file
V
V
V
Last edited on
Compiling:
To build and run:
----------------------
g++ *.cpp -std=c++11 -Wall -Wpedantic -o ast3
./ast3

It should match the output below:

Enter input File Name:
bankData.csv
Main Menu
Please make your selection
D - Deposit money
W - Withdraw money
Q - Quit
Selection:
d
Enter Account Type name: Saving or Checking
saving
Enter Account Number:
15656148
Enter Deposit Amount:
5000
******** Account Information before transaction ***************
Savings ACCT#:
Account Type : Saving
Account Number : 15656148
First Name : Josefa
Last Name : Opitz
Balance : $143800.00
Interest you can earn after 1 Year : $3595.00
Interest you can earn after 2 Year : $7190.00
Interest you can earn after 3 Year : $10785.00
********Account Information after transaction ***************
Savings ACCT#:
Account Type : Saving
Account Number : 15656148
First Name : Josefa
Last Name : Opitz
Balance : $148800.00
Interest you can earn after 1 Year : $3720.00
Interest you can earn after 2 Year : $7440.00
Interest you can earn after 3 Year : $11160.00
Main Menu
Please make your selection
D - Deposit money
W - Withdraw money
Q - Quit
Selection:
d
Enter Account Type name: Saving or Checking
Checking
>Checking account number is entered instead of savings account numberEnter Account Number:
15647311
Enter Deposit Amount:
8567
******** Account Information before transaction ***************
Checking ACCT#:
Account Type : Checking
Account Number : 15647311
First Name : Kendra
Last Name : Loud
Phone 1 : 5063631526
Balance : $18000.00
********Account Information after transaction ***************
Checking ACCT#:
Account Type : Checking
Account Number : 15647311
First Name : Kendra
Last Name : Loud
Phone 1 : 5063631526
Balance : $26567.00
Main Menu
Please make your selection
D - Deposit money
W - Withdraw money
Q - Quit
Selection:
w
Enter Account Type name: Saving or Checking
saving
Enter Account Number:
15592389
Enter Withdraw Amount:
10000
******** Account Information before transaction ***************
Savings ACCT#:
Account Type : Saving
Account Number : 15592389
First Name : Paola
Last Name : Vielma
Balance : $129000.00
Interest you can earn after 1 Year : $3225.00
Interest you can earn after 2 Year : $6450.00
Interest you can earn after 3 Year : $9675.00
********Account Information after transaction ***************
Savings ACCT#:
Account Type : Saving
Account Number : 15592389
First Name : Paola
Last Name : Vielma
Balance : $119000.00
Interest you can earn after 1 Year : $2975.00
Interest you can earn after 2 Year : $5950.00
Interest you can earn after 3 Year : $8925.00
Main Menu
Please make your selection
D - Deposit money
W - Withdraw money
Q - Quit
Selection:
w
Enter Account Type name: Saving or Checking
checking
Enter Account Number:
15792365
Enter Withdraw Amount: 330000
******** Account Information before transaction ***************
Checking ACCT#:
Account Type : Checking
Account Number : 15792365
First Name : Lea
Last Name : Steinhaus
Phone 1 : 9056188258
Balance : $331650.00
********Account Information after transaction ***************
Checking ACCT#:
Account Type : Checking
Account Number : 15792365
First Name : Lea
Last Name : Steinhaus
Phone 1 : 9056188258
Balance : $1650.00
Main Menu
Please make your selection
D - Deposit money
W - Withdraw money
Q - Quit
Selection:
q
Goodbye!

Any help will be appreciated.
Last edited on
please put code (and output too) in code tags, they are the <> on the format bar editor.

you can edit old posts to do that.

while (!inFile.eof()) may not work the way you think it should work.
generally we do while(getline) or while (file >> data) depending on how you process it.

1
2
3
4
5
in file open and probably other places, consider
bool foo()
{
   return (z == x); //the point?  you don't need bool tmp; if z!= x tmp = false else tmp = true return tmp ... bloated logic
}


bracket initialize variables is considered better than assignment. It it a little more strict and catches more errors. eg: bool b{false};

enough on the little stuff...
from what you left blank, well, you can't do it that way :)
a text file, to change anything, you change the whole file. read it all in and write it all back out with the new data. A binary file you can change just one field, but the only way you can do that in text is if the length of every item in the text is the same, eg a file of 4 digit numbers

so you have to have read the whole file into objects, modify the correct object and its field, and then just overwrite the whole file again when asked to do so or when logic dictates it (eg end of program). So your functions don't save the file, they change your data in memory in your objects and you write the changes somewhere else (or you can overwrite the file every operation if you want, does not hurt anything for small files)

c++ has numerous ways to do text to number and numbers to text. streams are the most used in modern code but stod stoi (string to double, string to int) are nice at times. If you must do that by hand, its tricky to cover all the cases but if the format style is known its not so bad, eg isdigit X power of 10 added up (the powers decrease and you know how large a phone number will be and possibly the acct num as well, if not have to iterate backwards) for simple int formats like phone num and similar for doubles but when you find the period you also divide by powers of 10.

your code is wordy in places (that is, it could be simplified a lot) but you have done some great work here. An example of that is just toupper function.
a fancy one: (this uses a mini-function called a lambda, its just for fun, you will get to them later)
1
2
3
4
5
std::string str_toupper(std::string s) 
{
    std::transform(s.begin(), s.end(), s.begin(), [](unsigned char c){ return std::toupper(c); });    
    return s;
}

a less fancy one: (this is a range based for loop, you may not have seen it either)
for( auto &c:s) c = toupper(c); //for every letter in s, called c by reference, upper case it.
and using what you surely know by now:
for(int i = 0; i < s.length(); i++) s[i] = toupper(s[i]); //if you need a copy not modify input then you can make sure that the input parameter is copied instead of referenced, and it will work, it makes the copy for you).
Last edited on
I passed when I say the length - and that it was split over 6 posts!

The first thing I noticed, though, was that you're passing containers (eg std::string) by val instead of by (const) ref. Passing by value causes an unnecessary copy.
That assignment is quite a mouthful.

For C++11 the header files need the following changes:
bankAccount.h
- needs #include <string>
- needs using std::string
- setBalance(int) should be setBalance(double)

fileOperation.h:
- needs #include <vector>

As for your code so far:

checkingAccount::withdraw() should use bankAccount::withdraw()
bankAccount::deposit() not implemented

And in fileOperationsImp.cpp:
- readFile() should not increment index. getNextField should do that for you.
- getNextField() doesn't look right to me.
- Pay attention the note on stringConvertDouble()

Since fileOperations has some complicated code, I suggest you temporarily use your own main() function to test the code in fileOperations. Start with getNextField(). Write a main program to read a line, then call getNextField() repeatedly until it returns false. After each call, print the resulting substring.

Are you allowed to add functions? It would be nice to write a saveFieldBankAccount() function that saves the fields of a bankAccount, Then saveFieldSavingsAccount() and saveFieldCheckingAccount() could each call saveFieldBankAccount() to deal with all the common fields.
Fixed the functions, but for some reason it still is having loads of errors during compiling. I'm going to break this up over two posts because it is so long, please pardon the length. It is not indicated that these are to be done in C++11 just C++. This is the code for the functions of fileOperationImp.cpp:
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
228
229
230
231
#include <iostream>
#include <iomanip>
#include <sstream>
#include <string>
#include <vector>

#include "savingsAccount.h"
#include "checkingAccount.h"
#include "fileOperation.h"
#include "bankAccount.h"

/**
 * @brief takes in a string and makes every element in the string to Upper Case
 * 
 * @param s the string to make uppercase
 * @return string returns upercase string
 */
string makeStringUpper(string s)
{
    string stringToReturn = s;

    for (char &c : stringToReturn)
    {
        c = toupper(c);
    }
    return stringToReturn;
}

/**
 * @brief reads in all data from the csv file and makes each line into structs
 * 
 * @param inFile the file to read from
 * @param item the vector to add each item
 * @param count how many objects are created from the file
 */
void readFile(ifstream &inFile, vector<checkingAccount> &Caccount, vector<savingsAccount> &Saccount, int &count)
{
    checkingAccount checkingItemHold = {};
    savingsAccount savingItemHold = {};
    string lineFromDataBaseFile;

    while (getline(inFile, lineFromDataBaseFile))
    {
        int fieldNumber = 0;
        int index = 0;

        for (int i = 0; i < 11; i++)
        {
            string individualDataElementFromLineRead = "";
            getNextField(lineFromDataBaseFile, index, individualDataElementFromLineRead);
            saveFieldCheckingAccount(fieldNumber, individualDataElementFromLineRead, checkingItemHold);
            saveFieldSavingAccount(fieldNumber, individualDataElementFromLineRead, savingItemHold);
            fieldNumber++;

            individualDataElementFromLineRead = "";
        }
        if (checkingItemHold.getAccountType() == "Checking")
        {
            Caccount.push_back(checkingItemHold);
            count++;
        }

        if (savingItemHold.getAccountType() == "Saving")
        {
            Saccount.push_back(savingItemHold);
            count++;
        }

        fieldNumber = 0;
    }
}

/**
 * @brief A function that writes that savings/checking accounts in memory to file
 * 
 * @param savingFile Puts all savings accounts in this file
 * @param checkingFile Puts all checking accounts in this file
 * @param Caccount array of all checking accounts
 * @param Saccount array of all saving accounts
 * @param count counts of all data points read
 */
void writeFile(ofstream &savingFile, ofstream &checkingFile, vector<checkingAccount> &Caccount, vector<savingsAccount> &Saccount, int &count)
{
    checkingFile << "Account Type,Account Number,first_name,last_name,company_name,address,city,phone1,phone2,Balance" << endl;

    for (checkingAccount singleAccount : Caccount)
    {

        checkingFile << singleAccount.getAccountType() << " " << singleAccount.getAccountNumber() << " " << singleAccount.getFirstName() << " " << singleAccount.getLastName() << " " << singleAccount.getCompanyName() << " " << singleAccount.getAddress() << " " << singleAccount.getCity() << " " << singleAccount.getPhone1() << " " << singleAccount.getPhone2() << " " << singleAccount.getBalance() << " " << endl;
        checkingFile << endl;
    }

    savingFile << "Account Type,Account Number,first_name,last_name,company_name,address,city,phone1,phone2,Balance" << endl;
    for (savingsAccount singleAccount : Saccount)
    {
        savingFile << singleAccount.getAccountType() << " " << singleAccount.getAccountNumber() << " " << singleAccount.getFirstName() << " " << singleAccount.getLastName() << " " << singleAccount.getCompanyName() << " " << singleAccount.getAddress() << " " << singleAccount.getCity() << " " << singleAccount.getPhone1() << " " << singleAccount.getPhone2() << " " << singleAccount.getBalance() << " " << endl;
        savingFile << endl;
    }
}

/**
 * @brief Opens the file. If the file location is incorrect keeps asking until its open
 * or the user pressed q
 * @param inFile the file to be passed in
 * @return true if the file is pened
 * @return false if the file location does not exsist/error in opening file
 */
bool openInputFile(ifstream &inFile)
{
    cout << "Enter input File Name/(q-quit): ";
    string userEnteredFileLocation;
    cin >> userEnteredFileLocation;
    if (userEnteredFileLocation == "q" || userEnteredFileLocation == "Q")
    {
        return false;
    }

    inFile.open(userEnteredFileLocation);
    if (inFile.is_open())
    {
        cout << "File opened correctly" << endl;
        cout << "----------------------" << endl;
        return true;
    }
    else
    {
        while (!inFile.is_open())
        {
            inFile.close();
            cout << "There was an error opening the file, please enter the file location again or press q to quit:  ";
            cin >> userEnteredFileLocation;
            if (userEnteredFileLocation == "q" || userEnteredFileLocation == "Q")
            {
                return false;
            }
            inFile.open(userEnteredFileLocation);
            if (inFile.is_open())
            {
                return true;
            }
        }
    }

    return false;
}

/**
 * @brief Get the Next Field object
 * 
 * @param line the line from the csv file
 * @param index what index we are at in the csv line
 * @param subString the data from that line
 * @return true if the word parsing is complete
 * @return false 
 */
bool getNextField(string &line, int &index, string &subString)
{
    for (int i = index; i < line.size(); i++)
    {
        if (line[i] != ',')
        {
            subString += line[i];
            index++;
        }
        else if (line[i] == ',')
        {
            index++;
            return true;
        }
    }
    return false;
}

/**
 * @brief takes in parsed string from a csv file and adds the item to the instance object
 * 
 * @param fieldNumber what index the information is to be added at to the struct
 * @param subString the parsed data from the csv to add to the instance object
 * @param tempItem the item to save to the instance object
 */
void saveFieldSavingAccount(int fieldNumber, string subString, savingsAccount &tempItem)
{
    if (fieldNumber == 0)
    {
        tempItem.setAccountType(subString);
    }
    else if (fieldNumber == 1)
    {
        tempItem.setAccountNumber(stringConvertInt(subString));
    }
    else if (fieldNumber == 2)
    {
        tempItem.setFirstName(subString);
    }
    else if (fieldNumber == 3)
    {
        tempItem.setLastName(subString);
    }
    else if (fieldNumber == 4)
    {
        tempItem.setCompanyName(subString);
    }
    else if (fieldNumber == 5)
    {
        tempItem.setAddress(subString);
    }
    else if (fieldNumber == 6)
    {
        tempItem.setCity(subString);
    }
    else if (fieldNumber == 7)
    {
        tempItem.setPhone1(stringConvertInt(subString));
    }
    else if (fieldNumber == 8)
    {
        tempItem.setPhone2(stringConvertInt(subString));
    }
    else if (fieldNumber == 9)
    {
        tempItem.setBalance(stringConvertDouble(subString));
    }
}

/**
 * @brief takes in parsed string from a csv file and adds the item to the instance object
 * 
 * @param fieldNumber what index the information is to be added at to the struct
 * @param subString the parsed data from the csv to add to the instance object
 * @param tempItem the item to save to the instance object
 */
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
void saveFieldCheckingAccount(int fieldNumber, string subString, checkingAccount &tempItem)
{
    if (fieldNumber == 0)
    {
        tempItem.setAccountType(subString);
    }
    else if (fieldNumber == 1)
    {
        tempItem.setAccountNumber(stringConvertInt(subString));
    }
    else if (fieldNumber == 2)
    {
        tempItem.setFirstName(subString);
    }
    else if (fieldNumber == 3)
    {
        tempItem.setLastName(subString);
    }
    else if (fieldNumber == 4)
    {
        tempItem.setCompanyName(subString);
    }
    else if (fieldNumber == 5)
    {
        tempItem.setAddress(subString);
    }
    else if (fieldNumber == 6)
    {
        tempItem.setCity(subString);
    }
    else if (fieldNumber == 7)
    {
        tempItem.setPhone1(stringConvertInt(subString));
    }
    else if (fieldNumber == 8)
    {
        tempItem.setPhone2(stringConvertInt(subString));
    }
    else if (fieldNumber == 9)
    {
        tempItem.setBalance(stringConvertDouble(subString));
    }
}

/**
 * @brief takes in a string and converts it to double
 * 
 * @param s the string to convert into a double
 * @return double the double returned when the string is converted 
 */
double stringConvertDouble(string s)
{
    double doubleToReturn = 0.0;
    stringstream stringToConvert;
    stringToConvert << s;
    stringToConvert >> doubleToReturn;
    return doubleToReturn;
}

/**
 * @brief takes in a string and converts it to long int
 * 
 * @param s the string to convert into a long int
 * @return long int the long int returned when the string is converted 
 */
long int stringConvertInt(string s)
{
    long int intToReturn = 0.0;
    stringstream stringToConvert;
    stringToConvert << s;
    stringToConvert >> intToReturn;
    return intToReturn;
}

/**
 * @brief Updates savings/checking accounts with the values user entered with error checks
 * 
 * @param Caccount array of all checking accounts
 * @param Saccount array of all savings account
 * @param deposit_f marked true if user wants to deposit
 * @param withdraw_f marked true if user wants to withdraw
 * @return int never understood what they wanted to return 
 */
int processMoney(vector<checkingAccount> &Caccount, vector<savingsAccount> &Saccount, bool deposit_f, bool withdraw_f)
{
    string userInput;
    cout << "Enter Account Type name: Saving or Checking" << endl;
    cin >> userInput;
    string upperCheck = makeStringUpper(userInput);

    if (upperCheck != "CHECKING" && upperCheck != "SAVING")
    {
        cout << "###########################################################" << endl;
        cout << "Error : Entered Account type wrong, Account type should be saving or checking " << endl;
        cout << "###########################################################" << endl;
        return 0; 
    }

    string accountNumber;
    cout << "Enter Account Number: " << endl;
    cin >> accountNumber;

    bool accountNumberCheck = false;

    for (savingsAccount singleAccount : Saccount)
    {
        if (upperCheck == "SAVING")
        {
            if (stringConvertInt(accountNumber) == singleAccount.getAccountNumber())
            {
                accountNumberCheck = true;
            }
        }
    }

    for (checkingAccount singleAccount : Caccount)
    {
        if (upperCheck == "CHECKING")
        {
            if (stringConvertInt(accountNumber) == singleAccount.getAccountNumber())
            {
                accountNumberCheck = true;
            }
        }
    }

    string dollarAmount;

    if (deposit_f == true)
    {
        cout << "Enter the Deposit Amount" << endl;
        cin >> dollarAmount;
    }

    if (withdraw_f == true)
    {
        cout << "Enter the Withdraw Amount" << endl;
        cin >> dollarAmount;
    }

    if (accountNumberCheck == false)
    {
        cout << "###########################################################" << endl;
        cout << "Error: Given Account number not present in Saving Account Type" << endl;
        cout << "###########################################################" << endl;
        return -1;
    }

    if (upperCheck == "SAVING")
    {
        stringConvertDouble(dollarAmount);
        stringConvertInt(accountNumber);
        for (savingsAccount singleAccount : Saccount)
        {

            if (stringConvertInt(accountNumber) == singleAccount.getAccountNumber())
            {
                cout << "******** Account Information before transaction ***************" << endl;
                singleAccount.print();
                if (deposit_f == true)
                {
                    singleAccount.deposit(stringConvertDouble(dollarAmount));
                }
                if (withdraw_f == true)
                {
                    singleAccount.withdraw(stringConvertDouble(dollarAmount));
                }

                cout << "********Account Information after transaction ***************" << endl;
                singleAccount.print();
            }
        }
    }

    if (upperCheck == "CHECKING")
    {
        stringConvertDouble(dollarAmount);
        stringConvertInt(accountNumber);
        for (checkingAccount singleAccount : Caccount)
        {

            if (stringConvertInt(accountNumber) == singleAccount.getAccountNumber())
            {
                cout << "******** Account Information before transaction ***************" << endl;
                singleAccount.print();
                if (deposit_f == true)
                {
                    singleAccount.deposit(stringConvertDouble(dollarAmount));
                }
                if (withdraw_f == true)
                {
                    singleAccount.withdraw(stringConvertDouble(dollarAmount));
                }

                cout << "********Account Information after transaction ***************" << endl;
                singleAccount.print();
            }
        }
    }

    return 1;
}
@GroovyJack. This is quite a complicated exercise. Also you now have another post http://www.cplusplus.com/forum/general/278472/ re a pond simulator which again seems non-trivial.

May I suggest that you concentrate on one project at a time and complete that before starting another.

Also I suggest that you first design the programs before coding. Then code the program in small parts - and getting each part to compile OK and tested before coding another part. This way if there is a compiler error or something doesn't work as expected, then the issue is in the latest added code. Compile and test frequently! The last thing you want to do is to write several hundred lines of code over multiple units and then compile and get loads of compile errors - or the program not working.
Last edited on
Your fileOperationImp.cpp compiles for me. If you're having compiler errors then it's probably the problems in the header files that I mentioned already.

I have to say that this assignment isn't teaching good C++, and by forcing you to implement it a particular way, it's actually teaching you bad C++ habits. The way that it reads and writes the data with getNextField() and saveFieldCheckingAccount/saveFieldSavingsAccount is just bizarre. It would make far more sense for each class to have it's own method to read the account information directly. ReadFile() would read the first field, decide it it was a checking or savings account, and read then use the appropriate instance to read the rest of the data. That would cut the amount of code for I/O in half, at least.

Unfortunately, you're stuck with what the prof demands, but hopefully, but realizing that dictated code structure isn't very good, you'll avoid bad habits in the future.
Can you post bankData.csv?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Account Type,Account Number,first_name,last_name,company_name,address,city,phone1,phone2,Balance
Saving,15592389,Paola,Vielma,Congress Title,58 Hancock St,Aurora,9054561117,9052637711,129000
Checking,15767821,Hortencia,Bresser,Batavia Chamber Of Commerce,808 Calle De Industrias,New Waterford,9022566791,9023708282,230013
Saving,15737173,Leanna,Tijerina,Stephenson Land Surveying,2859 Dorsett Rd,North York,4167192114,4166581773,367900
Saving,15632264,Danilo,Pride,Harry L Adams Incorporated,6857 Wall St,Red Deer,4032124945,4038889985,108000
Checking,15691483,Huey,Marcille,Southern Idaho Pipe & Stl Corp,169 Journal Sq,Edmonton,7806393619,7805201241,64800
Saving,15600882,Apolonia,Warne,Kitchen People,3 E 31st St #77,Fredericton,5069781488,5062211874,141000
Saving,15643966,Chandra,Lagos,Meredith Realty Group Inc,7 N Dean St,Etobicoke,4167166446,4168221760,61750
Checking,15737452,Crissy,Pacholec,Cgi Systems Inc,85 S State St,Barrie,7054772307,7055236746,67920
Saving,15788218,Gianna,Branin,All Brevard Cert Apprsls Inc,100 Main St,Calgary,4033377162,4035405944,78100
Saving,15661507,Valentin,Billa,General Color Co Inc,6185 Bohn St #72,Pangman,3062915073,3063167477,35650
Checking,15634602,Francoise,Rautenstrauch,Riebesell H F Jr,2335 Canton Hwy #6,Windsor,5195698399,5199786179,133900
Checking,15647311,Kendra,Loud,Deloitte & Touche,6 Arch St #9757,Alcida,5063631526,5069324472,18000
Saving,15619304,Lourdes,Bauswell,Oklahoma Neon Inc,9547 Belmont Rd #21,Belleville,6139037043,6136386682,5000
Checking,15701354,Hannah,Edmison,M B A Paint Stores,73 Pittsford Victor Rd,Vancouver,6043343686,6046927694,195800
Saving,15737888,Tom,Loeza,Sheraton Shreveport Hotel,447 Commercial St Se,LIle-Perrot,5144876096,5147274760,81600
Checking,15574012,Queenie,Kramarczyk,Goeman Wood Products Inc,47 Garfield Ave,Swift Current,3064215793,3063027591,41800
Checking,15592531,Hui,Portaro,A Storage Inn Of Gloucester,3 Mill Rd,Baker Brook,5068277755,5062764830,98500
Saving,15656148,Josefa,Opitz,Norman Gale Isuzu,136 W Grand Ave #3,Delhi,5197887645,5195263721,143800
Checking,15792365,Lea,Steinhaus,James Christopher Esq,80 Maplewood Dr #34,Bradford,9056188258,9056513298,331650 


there it is @dhayden. Also yes the program I am in is an elitist stint because they didn't get their funding and department raise a few years back so they take out their anger on students by making them do these in a beginner level C++ class. Even with the codes above compiling, it will not execute and I can't get the output right. Perhaps there is something wrong in bankAccountImp.cpp?
Last edited on
Thanks for posting that.

It's a beginner level problem, but they've imposed a convoluted solution upon you. That's what makes the solution difficult. I'll look at the code later when I get to my other computer, which has the code so far.
Yes thank you for responding so soon, I have found multiple other solutions for it without the 4-way split, they usually just have the driver file (bankmain.cpp) and checking files (.h/.cpp) and saving files (.h/.cpp) not this split with 9 files plus the .csv file! Any help in rectifying this would be grateful, here are the errors I get upon compilation:

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
bankAccount.h:13:25: error: ‘string’ has not been declared
     void setAccountType(string accType);
                         ^~~~~~
bankAccount.h:14:23: error: ‘string’ has not been declared
     void setFirstName(string firstName);
                       ^~~~~~
bankAccount.h:15:22: error: ‘string’ has not been declared
     void setLastName(string lastName);
                      ^~~~~~
bankAccount.h:16:25: error: ‘string’ has not been declared
     void setCompanyName(string companyName);
                         ^~~~~~
bankAccount.h:17:21: error: ‘string’ has not been declared
     void setAddress(string address);
                     ^~~~~~
bankAccount.h:18:18: error: ‘string’ has not been declared
     void setCity(string city);
                  ^~~~~~
bankAccount.h:24:5: error: ‘string’ does not name a type
     string getAccountType() const;
     ^~~~~~
bankAccount.h:25:5: error: ‘string’ does not name a type
     string getFirstName() const;
     ^~~~~~
bankAccount.h:26:5: error: ‘string’ does not name a type
     string getLastName() const;
     ^~~~~~
bankAccount.h:27:5: error: ‘string’ does not name a type
     string getCompanyName() const;
     ^~~~~~
bankAccount.h:28:5: error: ‘string’ does not name a type
     string getAddress() const;
     ^~~~~~
bankAccount.h:29:5: error: ‘string’ does not name a type
     string getCity() const;
     ^~~~~~
bankAccount.h:42:5: error: ‘string’ does not name a type
     string accountType;
     ^~~~~~
bankAccount.h:43:5: error: ‘string’ does not name a type
     string firstName;
     ^~~~~~
bankAccount.h:44:5: error: ‘string’ does not name a type
     string lastName;
     ^~~~~~
bankAccount.h:45:5: error: ‘string’ does not name a type
     string companyName;
     ^~~~~~
bankAccount.h:46:5: error: ‘string’ does not name a type
     string address;
     ^~~~~~
bankAccount.h:47:5: error: ‘string’ does not name a type
     string city;
     ^~~~~~
In file included from bankAccountImp.cpp:4:0:
bankAccount.h:13:25: error: ‘string’ has not been declared
     void setAccountType(string accType);
                         ^~~~~~
bankAccount.h:14:23: error: ‘string’ has not been declared
     void setFirstName(string firstName);
                       ^~~~~~
bankAccount.h:15:22: error: ‘string’ has not been declared
     void setLastName(string lastName);
                      ^~~~~~
bankAccount.h:16:25: error: ‘string’ has not been declared
     void setCompanyName(string companyName);
                         ^~~~~~
bankAccount.h:17:21: error: ‘string’ has not been declared
     void setAddress(string address);
                     ^~~~~~
bankAccount.h:18:18: error: ‘string’ has not been declared
     void setCity(string city);
                  ^~~~~~
bankAccount.h:24:5: error: ‘string’ does not name a type
     string getAccountType() const;
     ^~~~~~
bankAccount.h:25:5: error: ‘string’ does not name a type
     string getFirstName() const;
     ^~~~~~
bankAccount.h:26:5: error: ‘string’ does not name a type
     string getLastName() const;
     ^~~~~~
bankAccount.h:27:5: error: ‘string’ does not name a type
     string getCompanyName() const;
     ^~~~~~
bankAccount.h:28:5: error: ‘string’ does not name a type
     string getAddress() const;
     ^~~~~~
bankAccount.h:29:5: error: ‘string’ does not name a type
     string getCity() const;
     ^~~~~~
bankAccount.h:42:5: error: ‘string’ does not name a type
     string accountType;
     ^~~~~~
bankAccount.h:43:5: error: ‘string’ does not name a type
     string firstName;
     ^~~~~~
bankAccount.h:44:5: error: ‘string’ does not name a type
     string lastName;
     ^~~~~~
bankAccount.h:45:5: error: ‘string’ does not name a type
     string companyName;
     ^~~~~~
bankAccount.h:46:5: error: ‘string’ does not name a type
     string address;
     ^~~~~~
bankAccount.h:47:5: error: ‘string’ does not name a type
     string city;
     ^~~~~~
continued errors:

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
bankAccountImp.cpp:16:6: error: prototype forvoid bankAccount::setBalance(double)’ does not match any in class ‘bankAccount’
 void bankAccount::setBalance(double bal)
      ^~~~~~~~~~~
In file included from bankAccountImp.cpp:4:0:
bankAccount.h:21:10: error: candidate is: void bankAccount::setBalance(int)
     void setBalance(int balance);
          ^~~~~~~~~~
bankAccountImp.cpp:24:6: error: prototype forvoid bankAccount::setAccountType(std::string)’ does not match any in class ‘bankAccount’
 void bankAccount::setAccountType(string input)
      ^~~~~~~~~~~
In file included from bankAccountImp.cpp:4:0:
bankAccount.h:13:10: error: candidate is: void bankAccount::setAccountType(int)
     void setAccountType(string accType);
          ^~~~~~~~~~~~~~
bankAccountImp.cpp:29:6: error: prototype forvoid bankAccount::setFirstName(std::string)’ does not match any in class ‘bankAccount’
 void bankAccount::setFirstName(string input)
      ^~~~~~~~~~~
In file included from bankAccountImp.cpp:4:0:
bankAccount.h:14:10: error: candidate is: void bankAccount::setFirstName(int)
     void setFirstName(string firstName);
          ^~~~~~~~~~~~
bankAccountImp.cpp:34:6: error: prototype forvoid bankAccount::setLastName(std::string)’ does not match any in class ‘bankAccount’
 void bankAccount::setLastName(string input)
      ^~~~~~~~~~~
In file included from bankAccountImp.cpp:4:0:
bankAccount.h:15:10: error: candidate is: void bankAccount::setLastName(int)
     void setLastName(string lastName);
          ^~~~~~~~~~~
bankAccountImp.cpp:39:6: error: prototype forvoid bankAccount::setCompanyName(std::string)’ does not match any in class ‘bankAccount’
 void bankAccount::setCompanyName(string input)
      ^~~~~~~~~~~
In file included from bankAccountImp.cpp:4:0:
bankAccount.h:16:10: error: candidate is: void bankAccount::setCompanyName(int)
     void setCompanyName(string companyName);
          ^~~~~~~~~~~~~~
bankAccountImp.cpp:44:6: error: prototype forvoid bankAccount::setAddress(std::string)’ does not match any in class ‘bankAccount’
 void bankAccount::setAddress(string input)
      ^~~~~~~~~~~
In file included from bankAccountImp.cpp:4:0:
bankAccount.h:17:10: error: candidate is: void bankAccount::setAddress(int)
     void setAddress(string address);
          ^~~~~~~~~~
bankAccountImp.cpp:49:6: error: prototype forvoid bankAccount::setCity(std::string)’ does not match any in class ‘bankAccount’
 void bankAccount::setCity(string input)
      ^~~~~~~~~~~
In file included from bankAccountImp.cpp:4:0:
bankAccount.h:18:10: error: candidate is: void bankAccount::setCity(int)
     void setCity(string city);
          ^~~~~~~
bankAccountImp.cpp:80:36: error: no ‘std::string bankAccount::getFirstName() const’ member function declared in class ‘bankAccount’
 string bankAccount::getFirstName() const
                                    ^~~~~
bankAccountImp.cpp:85:35: error: no ‘std::string bankAccount::getLastName() const’ member function declared in class ‘bankAccount’
 string bankAccount::getLastName() const
                                   ^~~~~
bankAccountImp.cpp:90:38: error: no ‘std::string bankAccount::getCompanyName() const’ member function declared in class ‘bankAccount’
 string bankAccount::getCompanyName() const
                                      ^~~~~
bankAccountImp.cpp:95:34: error: no ‘std::string bankAccount::getAddress() const’ member function declared in class ‘bankAccount’
 string bankAccount::getAddress() const
                                  ^~~~~
bankAccountImp.cpp:100:31: error: no ‘std::string bankAccount::getCity() const’ member function declared in class ‘bankAccount’
 string bankAccount::getCity() const
                               ^~~~~
In file included from checkingAccount.h:7:0,
                 from checkingAccountImp.cpp:1:
bankAccount.h:13:25: error: ‘string’ has not been declared
     void setAccountType(string accType);
                         ^~~~~~
bankAccount.h:14:23: error: ‘string’ has not been declared
     void setFirstName(string firstName);
                       ^~~~~~
bankAccount.h:15:22: error: ‘string’ has not been declared
     void setLastName(string lastName);
                      ^~~~~~
bankAccount.h:16:25: error: ‘string’ has not been declared
     void setCompanyName(string companyName);
                         ^~~~~~
bankAccount.h:17:21: error: ‘string’ has not been declared
     void setAddress(string address);
                     ^~~~~~
bankAccount.h:18:18: error: ‘string’ has not been declared
     void setCity(string city);
                  ^~~~~~
bankAccount.h:24:5: error: ‘string’ does not name a type
     string getAccountType() const;
     ^~~~~~
bankAccount.h:25:5: error: ‘string’ does not name a type
     string getFirstName() const;
     ^~~~~~
bankAccount.h:26:5: error: ‘string’ does not name a type
     string getLastName() const;
     ^~~~~~
bankAccount.h:27:5: error: ‘string’ does not name a type
     string getCompanyName() const;
     ^~~~~~
bankAccount.h:28:5: error: ‘string’ does not name a type
     string getAddress() const;
     ^~~~~~
bankAccount.h:29:5: error: ‘string’ does not name a type
     string getCity() const;
     ^~~~~~
bankAccount.h:42:5: error: ‘string’ does not name a type
     string accountType;
     ^~~~~~
bankAccount.h:43:5: error: ‘string’ does not name a type
     string firstName;
     ^~~~~~
bankAccount.h:44:5: error: ‘string’ does not name a type
     string lastName;
     ^~~~~~
bankAccount.h:45:5: error: ‘string’ does not name a type
     string companyName;
     ^~~~~~
bankAccount.h:46:5: error: ‘string’ does not name a type
     string address;
     ^~~~~~
bankAccount.h:47:5: error: ‘string’ does not name a type
     string city;
     ^~~~~~
checkingAccountImp.cpp:16:6: error: prototype forvoid checkingAccount::print()’ does not match any in class ‘checkingAccount’
 void checkingAccount::print()
      ^~~~~~~~~~~~~~~
Last edited on
continued...

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
In file included from checkingAccountImp.cpp:1:0:
checkingAccount.h:17:10: error: candidate is: void checkingAccount::print() const
     void print() const; //This function should outputs the values of instance variables
          ^~~~~
In file included from savingsAccount.h:6:0,
                 from savingsAccountImp.cpp:1:
bankAccount.h:13:25: error: ‘string’ has not been declared
     void setAccountType(string accType);
                         ^~~~~~
bankAccount.h:14:23: error: ‘string’ has not been declared
     void setFirstName(string firstName);
                       ^~~~~~
bankAccount.h:15:22: error: ‘string’ has not been declared
     void setLastName(string lastName);
                      ^~~~~~
bankAccount.h:16:25: error: ‘string’ has not been declared
     void setCompanyName(string companyName);
                         ^~~~~~
bankAccount.h:17:21: error: ‘string’ has not been declared
     void setAddress(string address);
                     ^~~~~~
bankAccount.h:18:18: error: ‘string’ has not been declared
     void setCity(string city);
                  ^~~~~~
bankAccount.h:24:5: error: ‘string’ does not name a type
     string getAccountType() const;
     ^~~~~~
bankAccount.h:25:5: error: ‘string’ does not name a type
     string getFirstName() const;
     ^~~~~~
bankAccount.h:26:5: error: ‘string’ does not name a type
     string getLastName() const;
     ^~~~~~
bankAccount.h:27:5: error: ‘string’ does not name a type
     string getCompanyName() const;
     ^~~~~~
bankAccount.h:28:5: error: ‘string’ does not name a type
     string getAddress() const;
     ^~~~~~
bankAccount.h:29:5: error: ‘string’ does not name a type
     string getCity() const;
     ^~~~~~
bankAccount.h:42:5: error: ‘string’ does not name a type
     string accountType;
     ^~~~~~
bankAccount.h:43:5: error: ‘string’ does not name a type
     string firstName;
     ^~~~~~
bankAccount.h:44:5: error: ‘string’ does not name a type
     string lastName;
     ^~~~~~
bankAccount.h:45:5: error: ‘string’ does not name a type
     string companyName;
     ^~~~~~
bankAccount.h:46:5: error: ‘string’ does not name a type
     string address;
     ^~~~~~
bankAccount.h:47:5: error: ‘string’ does not name a type
     string city;
     ^~~~~~
savingsAccountImp.cpp:21:6: error: prototype forvoid savingsAccount::print()’ does not match any in class ‘savingsAccount’
 void savingsAccount::print()
      ^~~~~~~~~~~~~~
In file included from savingsAccountImp.cpp:1:0:
savingsAccount.h:18:10: error: candidate is: void savingsAccount::print() const
     void print() const; //This function should outputs the values of instance variables
          ^~~~~
In file included from savingsAccount.h:6:0,
                 from fileOperation.h:11,
                 from fileOperationImp.cpp:1:
bankAccount.h:13:25: error: ‘string’ has not been declared
     void setAccountType(string accType);
                         ^~~~~~
bankAccount.h:14:23: error: ‘string’ has not been declared
     void setFirstName(string firstName);
                       ^~~~~~
bankAccount.h:15:22: error: ‘string’ has not been declared
     void setLastName(string lastName);
                      ^~~~~~
bankAccount.h:16:25: error: ‘string’ has not been declared
     void setCompanyName(string companyName);
                         ^~~~~~
bankAccount.h:17:21: error: ‘string’ has not been declared
     void setAddress(string address);
                     ^~~~~~
bankAccount.h:18:18: error: ‘string’ has not been declared
     void setCity(string city);
                  ^~~~~~
bankAccount.h:24:5: error: ‘string’ does not name a type
     string getAccountType() const;
     ^~~~~~
bankAccount.h:25:5: error: ‘string’ does not name a type
     string getFirstName() const;
     ^~~~~~
bankAccount.h:26:5: error: ‘string’ does not name a type
     string getLastName() const;
     ^~~~~~
bankAccount.h:27:5: error: ‘string’ does not name a type
     string getCompanyName() const;
     ^~~~~~
bankAccount.h:28:5: error: ‘string’ does not name a type
     string getAddress() const;
     ^~~~~~
bankAccount.h:29:5: error: ‘string’ does not name a type
     string getCity() const;
     ^~~~~~
bankAccount.h:42:5: error: ‘string’ does not name a type
     string accountType;
     ^~~~~~
bankAccount.h:43:5: error: ‘string’ does not name a type
     string firstName;
     ^~~~~~
bankAccount.h:44:5: error: ‘string’ does not name a type
     string lastName;
     ^~~~~~
bankAccount.h:45:5: error: ‘string’ does not name a type
     string companyName;
     ^~~~~~
bankAccount.h:46:5: error: ‘string’ does not name a type
     string address;
     ^~~~~~
bankAccount.h:47:5: error: ‘string’ does not name a type
     string city;
     ^~~~~~
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
In file included from fileOperationImp.cpp:1:0:
fileOperation.h:90:37: error: ‘vector’ has not been declared
     void readFile(ifstream &inFile, vector<checkingAccount> &Caccount, vector<savingsAccount> &Saccount, int &count);
                                     ^~~~~~
fileOperation.h:90:43: error: expected ‘,’ or ‘...’ before ‘<’ token
     void readFile(ifstream &inFile, vector<checkingAccount> &Caccount, vector<savingsAccount> &Saccount, int &count);
                                           ^
fileOperation.h:91:66: error: ‘vector’ has not been declared
     void writeFile(ofstream &savingFile, ofstream &checkingFile, vector<checkingAccount> &Caccount, vector<savingsAccount> &Saccount, int &count);
                                                                  ^~~~~~
fileOperation.h:91:72: error: expected ‘,’ or ‘...’ before ‘<’ token
     void writeFile(ofstream &savingFile, ofstream &checkingFile, vector<checkingAccount> &Caccount, vector<savingsAccount> &Saccount, int &count);
                                                                        ^
In file included from fileOperationImp.cpp:1:0:
fileOperation.h:98:22: error: ‘vector’ was not declared in this scope
     int processMoney(vector<checkingAccount> &Caccount, vector<savingsAccount> &Saccount, bool deposit_f, bool withdraw_f);
                      ^~~~~~
fileOperation.h:98:44: error: expected primary-expression before ‘>’ token
     int processMoney(vector<checkingAccount> &Caccount, vector<savingsAccount> &Saccount, bool deposit_f, bool withdraw_f);
                                            ^
fileOperation.h:98:47: error: ‘Caccount’ was not declared in this scope
     int processMoney(vector<checkingAccount> &Caccount, vector<savingsAccount> &Saccount, bool deposit_f, bool withdraw_f);
                                               ^~~~~~~~
fileOperation.h:98:57: error: ‘vector’ was not declared in this scope
     int processMoney(vector<checkingAccount> &Caccount, vector<savingsAccount> &Saccount, bool deposit_f, bool withdraw_f);
                                                         ^~~~~~
fileOperation.h:98:78: error: expected primary-expression before ‘>’ token
     int processMoney(vector<checkingAccount> &Caccount, vector<savingsAccount> &Saccount, bool deposit_f, bool withdraw_f);
                                                                              ^
fileOperation.h:98:81: error: ‘Saccount’ was not declared in this scope
     int processMoney(vector<checkingAccount> &Caccount, vector<savingsAccount> &Saccount, bool deposit_f, bool withdraw_f);
                                                                                 ^~~~~~~~
fileOperation.h:98:91: error: expected primary-expression before ‘boolint processMoney(vector<checkingAccount> &Caccount, vector<savingsAccount> &Saccount, bool deposit_f, bool withdraw_f);
                                                                                           ^~~~
fileOperation.h:98:107: error: expected primary-expression before ‘boolint processMoney(vector<checkingAccount> &Caccount, vector<savingsAccount> &Saccount, bool deposit_f, bool withdraw_f);
                                                                                                           ^~~~
fileOperation.h:98:122: error: expression list treated as compound expression in initializer [-fpermissive]
     int processMoney(vector<checkingAccount> &Caccount, vector<savingsAccount> &Saccount, bool deposit_f, bool withdraw_f);
                                                                                                                          ^
fileOperationImp.cpp: In function ‘std::string makeStringUpper(std::string)’:
fileOperationImp.cpp:12:32: error: ‘loc’ was not declared in this scope
         upper += toupper(s[x], loc);
                                ^~~
fileOperationImp.cpp: At global scope:
fileOperationImp.cpp:18:33: error: ‘vector’ has not been declared
 void readFile(ifstream &inFile, vector<checkingAccount> &Caccount, vector<savingsAccount> &Saccount, int &count)
                                 ^~~~~~
fileOperationImp.cpp:18:39: error: expected ‘,’ or ‘...’ before ‘<’ token
 void readFile(ifstream &inFile, vector<checkingAccount> &Caccount, vector<savingsAccount> &Saccount, int &count)
                                       ^
fileOperationImp.cpp: In function ‘void readFile(std::ifstream&, int)’:
fileOperationImp.cpp:42:17: error: ‘Caccount’ was not declared in this scope
                 Caccount.push_back(tempCaccount);
                 ^~~~~~~~
fileOperationImp.cpp:43:17: error: ‘count’ was not declared in this scope
                 count++;
                 ^~~~~
fileOperationImp.cpp:53:17: error: ‘Saccount’ was not declared in this scope
                 Saccount.push_back(tempSaccount);
                 ^~~~~~~~
fileOperationImp.cpp:54:17: error: ‘count’ was not declared in this scope
                 count++;
                 ^~~~~
fileOperationImp.cpp: At global scope:
fileOperationImp.cpp:65:3: error: expected unqualified-id before ‘bool’
 * bool openInputFile(ifstream &inFile)
   ^~~~
fileOperationImp.cpp:65:3: error: expected constructor, destructor, or type conversion before ‘bool’
In file included from savingsAccount.h:6:0,
                 from fileOperationImp2.cpp:7:
bankAccount.h:13:25: error: ‘string’ has not been declared
     void setAccountType(string accType);
                         ^~~~~~
bankAccount.h:14:23: error: ‘string’ has not been declared
     void setFirstName(string firstName);
                       ^~~~~~
bankAccount.h:15:22: error: ‘string’ has not been declared
     void setLastName(string lastName);
                      ^~~~~~
bankAccount.h:16:25: error: ‘string’ has not been declared
     void setCompanyName(string companyName);
                         ^~~~~~
bankAccount.h:17:21: error: ‘string’ has not been declared
     void setAddress(string address);
                     ^~~~~~
bankAccount.h:18:18: error: ‘string’ has not been declared
     void setCity(string city);
                  ^~~~~~
bankAccount.h:24:5: error: ‘string’ does not name a type
     string getAccountType() const;
     ^~~~~~
bankAccount.h:25:5: error: ‘string’ does not name a type
     string getFirstName() const;
     ^~~~~~
bankAccount.h:26:5: error: ‘string’ does not name a type
     string getLastName() const;
     ^~~~~~
bankAccount.h:27:5: error: ‘string’ does not name a type
     string getCompanyName() const;
     ^~~~~~
bankAccount.h:28:5: error: ‘string’ does not name a type
     string getAddress() const;
     ^~~~~~
bankAccount.h:29:5: error: ‘string’ does not name a type
     string getCity() const;
     ^~~~~~
bankAccount.h:42:5: error: ‘string’ does not name a type
     string accountType;
     ^~~~~~
bankAccount.h:43:5: error: ‘string’ does not name a type
     string firstName;
     ^~~~~~
bankAccount.h:44:5: error: ‘string’ does not name a type
     string lastName;
     ^~~~~~
bankAccount.h:45:5: error: ‘string’ does not name a type
     string companyName;
     ^~~~~~
bankAccount.h:46:5: error: ‘string’ does not name a type
     string address;
     ^~~~~~
bankAccount.h:47:5: error: ‘string’ does not name a type
     string city;
     ^~~~~~
fileOperationImp2.cpp: In function ‘void readFile(std::ifstream&, std::vector<checkingAccount>&, std::vector<savingsAccount>&, int&)’:
fileOperationImp2.cpp:57:30: error: ‘class checkingAccount’ has no member named ‘getAccountType’; did you mean ‘setAccountType’?
         if (checkingItemHold.getAccountType() == "Checking")
                              ^~~~~~~~~~~~~~
fileOperationImp2.cpp:63:28: error: ‘class savingsAccount’ has no member named ‘getAccountType’; did you mean ‘setAccountType’?
         if (savingItemHold.getAccountType() == "Saving")
                            ^~~~~~~~~~~~~~
Last edited on
Pages: 12