EDN Admin
Well-known member
Hello, Im trying to create a program which writes account info onto a separate file after reading the initial data from a separate file. During this the user may withdraw, deposit, check balances, etc. when using the program. Im getting two errors and I am at a loss as how to fix them, Ive tried what it suggests but to no avail, if anyone could point me in the right direction that would be a major help!
Header File:
#ifndef CUSTOMER_H
#define CUSTOMER_H
#include <string>
struct Date
{
int Day;
int Month;
int Year;
};
struct Name
{
std::string first_name;
std::string middle_name;
std::string last_name;
};
class customer
{
private:
Date birth_date;
Name name;
float balance_saving;
float balance_checking;
float initial_saving;
float initial_checking;
float amount;
float account_type;
public:
customer(); //Default constructor
customer(Date birth_date, Name name, float initial_saving, float initial_checking); // Parametrized constructor
void withdraw(float amount, int account_type);
void deposit(float amount, int account_type);
float check_balance_saving(); // Print out the savings balance on screen
float check_balance_checking(); // Print out the checking balance on screen
void setDate(int Day, int Month, int Year);
Date getDate();
void setName(std::string first_name, std::string middle_name, std::string last_name);
Name getName();
void setSaving(float initial_saving);
void setChecking(float initial_checking);
};
#endif
Implementation File:
#include "customer.h"
//Default contructor
customer::customer()
{
birth_date.Day = 01;
birth_date.Month = 01;
birth_date.Year = 1901;
name.first_name = "N/A";
name.middle_name = "N/A";
name.last_name = "N/A";
balance_saving = 0;
balance_checking = 0;
}
// Parametrized constructor
customer::customer(Date a, Name b, float c, float d)
{
birth_date = a;
name = b;
initial_saving = c;
initial_checking = d;
}
void customer::withdraw(float e, int f)
{
amount = e;
account_type = f;
}
void customer::deposit(float g, int h)
{
amount = g;
account_type = h;
}
float customer::check_balance_saving()
{
return balance_saving;
}
float customer::check_balance_checking()
{
return balance_checking;
}
void customer::setDate(int i, int j, int k)
{
birth_date.Day = i;
birth_date.Month = j;
birth_date.Year = k;
}
Date customer::getDate()
{
return birth_date;
}
void customer::setName(std::string l, std::string m, std::string n)
{
name.first_name = l;
name.middle_name = m;
name.last_name = n;
}
Name customer::getName()
{
return name;
}
void customer::setSaving(float o)
{
initial_saving = o;
}
void customer::setChecking(float p)
{
initial_checking = p;
}
Main Routine:#include "customer.h"
#include <fstream>
#include <iostream>
#include <string>
using namespace std;
//Function prototypes
void withdrawl (customer[], int);
void deposit (customer[], int);
void checkBal (customer[], int);
void newAccountFile (customer[], int);
int main ()
{
int customerCount = 0; //Counter to count number of customers recorded in file
customer customerArray[100]; //Declare customer array
ifstream customerfile ("account.dat"); //Open existing customer file
while (!customerfile.eof()) //Loop reads in data from file
{
int D, M, Y; // Birth day, month, year
string FN, MN, LN; //First name, middle name, last name
float Save, Check; //Savings & Checking initial amount
customerfile >> D;
customerfile >> M;
customerfile >> Y;
customerfile >> FN;
customerfile >> MN;
customerfile >> LN;
customerfile >> Save;
customerfile >> Check;
customerArray[customerCount].setDate(D, M, Y);
customerArray[customerCount].setName(FN, MN, LN);
customerArray[customerCount].setSaving(Save);
customerArray[customerCount].setChecking(Check);
customerCount++;
}
customerfile.close(); //Close customer file and end file reading
//User menu
int accountNumber;
int option;
int D1, M1, Y1;
string FN1, MN1, LN1;
float Save1, Check1;
do
{
cout << "Type 1 for a withdrawl, 2 for deposit, 3 to check balance, 4 to create a new account, and 0 to exit the program: "<< endl;
cin >> option;
if (option == 1)
cout << "Enter the account number: " << endl;
cin >> accountNumber;
withdrawl(customerArray, accountNumber);
if (option == 2)
cout << "Enter the account number: " << endl;
cin >> accountNumber;
deposit(customerArray, accountNumber);
if (option == 3)
cout << "Enter the account number: " << endl;
cin >> accountNumber;
checkBal(customerArray, accountNumber);
if (option == 4)
cout << "Enter the new account information (Birth Info): " << endl;
cin >> D1 >> M1 >> Y1;
customerArray[customerCount + 1].setDate(D1, M1, Y1);
cout << "Enter the new accounts customer name: " << endl;
cin >> FN1 >> MN1 >> LN1;
customerArray[customerCount + 1].setName(FN1, MN1, LN1);
cout << "Enter the new savings balance: " << endl;
cin >> Save1;
customerArray[customerCount + 1].setSaving(Save1);
cout << "Enter the new checking balance: " << endl;
cin >> Check1;
customerArray[customerCount + 1].setChecking(Check1);
customerCount ++;
}while (option =! 0);
newAccountFile(customerArray, customerCount);
}
void withdrawl(customer customerArray[], int number)
{
float withdrawlAmount;
int optionWit;
float tempSave = 0;
float tempCheck = 0;
cout << "Enter 1 to withdrawl from savings, enter 2 to withdrawl from checking: " << endl;
cin >> optionWit;
cout << "Enter the amount to be withdrawn: ";
cin >> withdrawlAmount;
if (optionWit == 1)
tempSave = customerArray[number].check_balance_saving() - withdrawlAmount;
customerArray[number].setSaving(tempSave);
if (optionWit == 2)
tempCheck = customerArray[number].check_balance_checking() - withdrawlAmount;
customerArray[number].setChecking(tempCheck);
}
void desposit(customer customerArray[], int number)
{
float depositAmount;
int optionDep;
float tempSave;
float tempCheck;
cout << "Enter 1 to deposit to savings, enter 2 to deposit to checking: " << endl;
cin >> optionDep;
cout << "Enter the amount to be deposited: ";
cin >> depositAmount;
if (optionDep == 1)
tempSave = customerArray[number].check_balance_saving() + depositAmount;
customerArray[number].setSaving(tempSave);
if (optionDep == 2)
tempCheck = customerArray[number].check_balance_checking() + depositAmount;
customerArray[number].setChecking(tempCheck);
}
void checkBal(customer customerArray[], int number)
{
int optionBal;
cout << "Enter 1 to see savings balance, enter 2 to see checking balance: " << endl;
cin >> optionBal;
if (optionBal == 1)
cout << customerArray[number].check_balance_saving();
if (optionBal == 2)
cout << customerArray[number].check_balance_checking();
}
void newAccountFile(customer customerArray[], int size)
{
int i;
Date tempDate;
Name tempName;
ofstream newAccountStorage;
newAccountStorage.open ("updated_account.dat");
for (i = 0; i < size; i++);
{
newAccountStorage << customerArray.getName << endl;
newAccountStorage << customerArray.getDate << endl;
newAccountStorage << customerArray.check_balance_saving() << endl;
newAccountStorage << customerArray.check_balance_checking() << endl;
}
newAccountStorage.close();
}
Im getting errors on lines (155 & 156):
customer::getName: function call missing argument list; use &customer::getName to create a pointer to member
customer::getDate: function call missing argument list; use &customer::getDate to create a pointer to member
View the full article
Header File:
#ifndef CUSTOMER_H
#define CUSTOMER_H
#include <string>
struct Date
{
int Day;
int Month;
int Year;
};
struct Name
{
std::string first_name;
std::string middle_name;
std::string last_name;
};
class customer
{
private:
Date birth_date;
Name name;
float balance_saving;
float balance_checking;
float initial_saving;
float initial_checking;
float amount;
float account_type;
public:
customer(); //Default constructor
customer(Date birth_date, Name name, float initial_saving, float initial_checking); // Parametrized constructor
void withdraw(float amount, int account_type);
void deposit(float amount, int account_type);
float check_balance_saving(); // Print out the savings balance on screen
float check_balance_checking(); // Print out the checking balance on screen
void setDate(int Day, int Month, int Year);
Date getDate();
void setName(std::string first_name, std::string middle_name, std::string last_name);
Name getName();
void setSaving(float initial_saving);
void setChecking(float initial_checking);
};
#endif
Implementation File:
#include "customer.h"
//Default contructor
customer::customer()
{
birth_date.Day = 01;
birth_date.Month = 01;
birth_date.Year = 1901;
name.first_name = "N/A";
name.middle_name = "N/A";
name.last_name = "N/A";
balance_saving = 0;
balance_checking = 0;
}
// Parametrized constructor
customer::customer(Date a, Name b, float c, float d)
{
birth_date = a;
name = b;
initial_saving = c;
initial_checking = d;
}
void customer::withdraw(float e, int f)
{
amount = e;
account_type = f;
}
void customer::deposit(float g, int h)
{
amount = g;
account_type = h;
}
float customer::check_balance_saving()
{
return balance_saving;
}
float customer::check_balance_checking()
{
return balance_checking;
}
void customer::setDate(int i, int j, int k)
{
birth_date.Day = i;
birth_date.Month = j;
birth_date.Year = k;
}
Date customer::getDate()
{
return birth_date;
}
void customer::setName(std::string l, std::string m, std::string n)
{
name.first_name = l;
name.middle_name = m;
name.last_name = n;
}
Name customer::getName()
{
return name;
}
void customer::setSaving(float o)
{
initial_saving = o;
}
void customer::setChecking(float p)
{
initial_checking = p;
}
Main Routine:#include "customer.h"
#include <fstream>
#include <iostream>
#include <string>
using namespace std;
//Function prototypes
void withdrawl (customer[], int);
void deposit (customer[], int);
void checkBal (customer[], int);
void newAccountFile (customer[], int);
int main ()
{
int customerCount = 0; //Counter to count number of customers recorded in file
customer customerArray[100]; //Declare customer array
ifstream customerfile ("account.dat"); //Open existing customer file
while (!customerfile.eof()) //Loop reads in data from file
{
int D, M, Y; // Birth day, month, year
string FN, MN, LN; //First name, middle name, last name
float Save, Check; //Savings & Checking initial amount
customerfile >> D;
customerfile >> M;
customerfile >> Y;
customerfile >> FN;
customerfile >> MN;
customerfile >> LN;
customerfile >> Save;
customerfile >> Check;
customerArray[customerCount].setDate(D, M, Y);
customerArray[customerCount].setName(FN, MN, LN);
customerArray[customerCount].setSaving(Save);
customerArray[customerCount].setChecking(Check);
customerCount++;
}
customerfile.close(); //Close customer file and end file reading
//User menu
int accountNumber;
int option;
int D1, M1, Y1;
string FN1, MN1, LN1;
float Save1, Check1;
do
{
cout << "Type 1 for a withdrawl, 2 for deposit, 3 to check balance, 4 to create a new account, and 0 to exit the program: "<< endl;
cin >> option;
if (option == 1)
cout << "Enter the account number: " << endl;
cin >> accountNumber;
withdrawl(customerArray, accountNumber);
if (option == 2)
cout << "Enter the account number: " << endl;
cin >> accountNumber;
deposit(customerArray, accountNumber);
if (option == 3)
cout << "Enter the account number: " << endl;
cin >> accountNumber;
checkBal(customerArray, accountNumber);
if (option == 4)
cout << "Enter the new account information (Birth Info): " << endl;
cin >> D1 >> M1 >> Y1;
customerArray[customerCount + 1].setDate(D1, M1, Y1);
cout << "Enter the new accounts customer name: " << endl;
cin >> FN1 >> MN1 >> LN1;
customerArray[customerCount + 1].setName(FN1, MN1, LN1);
cout << "Enter the new savings balance: " << endl;
cin >> Save1;
customerArray[customerCount + 1].setSaving(Save1);
cout << "Enter the new checking balance: " << endl;
cin >> Check1;
customerArray[customerCount + 1].setChecking(Check1);
customerCount ++;
}while (option =! 0);
newAccountFile(customerArray, customerCount);
}
void withdrawl(customer customerArray[], int number)
{
float withdrawlAmount;
int optionWit;
float tempSave = 0;
float tempCheck = 0;
cout << "Enter 1 to withdrawl from savings, enter 2 to withdrawl from checking: " << endl;
cin >> optionWit;
cout << "Enter the amount to be withdrawn: ";
cin >> withdrawlAmount;
if (optionWit == 1)
tempSave = customerArray[number].check_balance_saving() - withdrawlAmount;
customerArray[number].setSaving(tempSave);
if (optionWit == 2)
tempCheck = customerArray[number].check_balance_checking() - withdrawlAmount;
customerArray[number].setChecking(tempCheck);
}
void desposit(customer customerArray[], int number)
{
float depositAmount;
int optionDep;
float tempSave;
float tempCheck;
cout << "Enter 1 to deposit to savings, enter 2 to deposit to checking: " << endl;
cin >> optionDep;
cout << "Enter the amount to be deposited: ";
cin >> depositAmount;
if (optionDep == 1)
tempSave = customerArray[number].check_balance_saving() + depositAmount;
customerArray[number].setSaving(tempSave);
if (optionDep == 2)
tempCheck = customerArray[number].check_balance_checking() + depositAmount;
customerArray[number].setChecking(tempCheck);
}
void checkBal(customer customerArray[], int number)
{
int optionBal;
cout << "Enter 1 to see savings balance, enter 2 to see checking balance: " << endl;
cin >> optionBal;
if (optionBal == 1)
cout << customerArray[number].check_balance_saving();
if (optionBal == 2)
cout << customerArray[number].check_balance_checking();
}
void newAccountFile(customer customerArray[], int size)
{
int i;
Date tempDate;
Name tempName;
ofstream newAccountStorage;
newAccountStorage.open ("updated_account.dat");
for (i = 0; i < size; i++);
{
newAccountStorage << customerArray.getName << endl;
newAccountStorage << customerArray.getDate << endl;
newAccountStorage << customerArray.check_balance_saving() << endl;
newAccountStorage << customerArray.check_balance_checking() << endl;
}
newAccountStorage.close();
}
Im getting errors on lines (155 & 156):
customer::getName: function call missing argument list; use &customer::getName to create a pointer to member
customer::getDate: function call missing argument list; use &customer::getDate to create a pointer to member
View the full article