Assignment Error Help

Having trouble with assignment

  • (3 Pages)
  • +
  • 1
  • 2
  • 3

36 Replies - 1384 Views - Last Post: 20 February 2010 - 05:01 PM Rate Topic: -----

#1 tarheelfan_08  Icon User is offline

  • D.I.C Regular

Reputation: -2
  • View blog
  • Posts: 256
  • Joined: 24-January 10

Assignment Error Help

Posted 15 February 2010 - 05:27 PM

I am having trouble with one of my school assignments. If someone can please help me with my errors I would be extremely happy! I will include my assignment, the 3 files(it’s a class) and the errors. If you need me to I can zip these filed and attach them!


1. You are a programmer that works for a local bank. You are creating classes to be used in the class library for this bank for all of its programs. You will also create a main() to test your new classes.

Talking to the bank manager you find out that the two main problem domain objects (“things” in our system we need to keep track of) are “Accounts” and “Customers”. You find out that customers have accounts, and that a customer can have more than one account (of different types like checking, savings, or overdraft/credit card.) Accounts are thought of as being distinct objects and should never be separated from the Customers that they are a part of.


Customer Class (20 points):
Attributes/data members:
name (a string)
ssn (a string)
address (a string)
birthdate (a Date)
savings (an Account)
checking (an Account)

behaviors/member functions:
1) accessor (get) and mutator (set) functions for all attributes.
2) DisplayCustomer(), this function should show a message on the console with the customer’s name, ssn, and the balances for each account.

Constructor(s):
This class must have a constructor that accepts all of the data to create a Customer and initializes its data members.

Date Class:
(This class is from your company’s current class library. See separate file for the date class. It is from page 714 in your book.)

Account Class (20 points):
Attributes/data members
number (an integer)
type (a string)
balance (a double)
rate (a double)

behaviors/member functions:
1) accessor (get) and mutator (set) functions for all attributes.
2) ApplyInterest(), this function should take the balance and multiply it by the rate to find the interest this period…then add it to the existing balance.

Constructor(s):
This class must have a constructor that accepts all of the data to create an Account and initializes its data members.

Validation in member functions/ Business Rules:
1) Rates should be between .01 and .10 (it is an interest rate as a decimal)
2) Balances should never be allowed to be set to a negative value.


2. (15 points)Add operator overloading to the Account class to allow the +, -, /, and * operators to be used to do mathematical calculations between two accounts.

Change the Customer class DisplayCustomer() function to show the consolidated balance as well. Create a temporary account and set it equal to savings + checking (using the overloaded + operator), then report its balance as the consolidated balance (or total balance if you prefer to call it this.)

3. (9 points)Create statements in main() to test your new classes.

1) Create two new customers in your program (with all their data.)

2) Display the customer information for your two customers using the DisplayCustomer() function.

3) Call the ApplyInterest() function to apply the interest for the current period.

4) Display the customer information for your two customers again using the DisplayCustomer() function.


Customer Header File

#ifndef CUSTOMER_H
#define CUSTOMER_H

#include <iostream>
#include <fstream>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <string>
#include <cstdlib>
#include <sstream>
using namespace std;

//Customer Class
class Customer {
private:
    string name;  //name of customer
    string ssn; // social security number
    string address;  // address
    int birthDate;	//birth date
    int	savings;  // savings account balance
    int checking;  // checking account balance
	int balance;	// Consoldated Balance

public:
    Customer(); //constructor
    Customer(string, string, string, int ,int, int, int);
    void setName(string);
    void setSSN(string);
    void setAddress(string);
    void setBirthDate(int);
    void setSavings(int);
    void setChecking(int);
	void setBalance(int);

    string getName();
    string getSSN();
    string getAddress();
    int getBirthDate();
    int getSavings();
    int getChecking();
	int getBalance();

	void displayCustomer();
	string string_displayCustomer();
};


//-----------------------------------------------------------------------------
//class definition
Customer::Customer() {
    name = " ";
    ssn = " ";
    address = " ";
    birthDate = 0;
    savings = 0;
	checking = 0;
	balance = 0;
}

Customer::Customer(string name, string ssn, string address, int birthDate, int savings, int checking, int balance) {
    Customer::name =  name;
    Customer::ssn = ssn;
    Customer::address = address;
    Customer::birthDate = birthDate;
    Customer::savings = savings;
    Customer::checking = checking;
	Customer::balance = balance;
}

void Customer::setName(string name) {
    Customer::name = name;
}

void Customer::setSSN(string ssn) {
    Customer::ssn = ssn;
}

void Customer::setAddress(string address) {
    Customer::address = address;
}

void Customer::setBirthDate(int birthDate) {
    Customer::birthDate = birthDate;
}

void Customer::setSavings(int savings) {
    Customer::savings = savings;
}

void Customer::setChecking(int checking) {
    Customer::checking = checking;
}

void Customer::setBalance(int balance) {
	Customer::balance = balance;
}



string Customer::getName() {
    return name;
}

string Customer::getSSN() {
    return ssn;
}

string Customer::getAddress() {
    return address;
}

int Customer::getBirthDate() {
    return birthDate;
}

int Customer::getSavings() {
    return savings;
}

int Customer::getChecking() {
    return checking;
}

int Customer::getBalance() {
	return balance;

}

void Customer::displayCustomer() {
    cout << "The current customer is " << name << ", their address is " << address << ", and their Social Security Number is "
		<< ssn << ".  "  << name << "'s Saving Account Ballance is:" << savings << ".  The Checking Account Balance is:" << checking << ".\n";
	cout << "The consolidated balance is: $" << balance << ".\n";
}

string Customer::string_displayCustomer() {
	stringstream buf;
	cout << "The current customer is " << name << ", their address is " << address << ", and their Social Security Number is "
	<< ssn << ".  "  << name << "'s Saving Account Ballance is:" << savings << ".  The Checking Account Balance is:" << checking << ".\n";
	cout << "The consolidated balance is: $" << balance << ".\n";
    return buf.str();
}
#endif




Account Header File

#ifndef ACCOUNT_H
#define ACCOUNT_H

#include "Customer.h"

//Account Class
class Account {
private:
	Customer myCustomer[2];
	string type;
	int number;
    double balance;
    double rate;
	double intrest;
	double NewBalance;

public:
	Account(); // Constructor
	Account(string, int, double, double) {
		void setType(string);
		void setNumber(int);
		void setBalance(double);
		void setRate(double);

		string getType();
		int getNumber();
		double getBalance();
		double getRate();

		void valid_Rate(double);
		void ApplyInterest();
	};
//-----------------------------------------------------------------------------
//class definition
	Account::Account() {
		type = " ";
		number = 0;
		balance = 0;
		rate = 0;
	}

	Account::Account(string type, int number, double balance, double rate) {
		Account::type = type;
		Account::number = number;
		Account::balance = balance;
		valid_rate(rate);
		}
void Account::setType(string type) {
    Account::type = type;
}

void Account::setNumber(int number) {
    Account::number = number;
}

void Account::setBalance(double balance) {
    Account::balance = balance;
}

void Account::setRate(double rate) {
	valid_rate(rate);
}

string Account::getType() {
    return type;
}
int Account::getNumber() {
    return number;
}
double Account::getBalance() {
    return balance;
}
double Account::getRate() {
    return rate;
}

void Account::valid_rate(double rate) {
	if (rate >=.01 && rate <= .1)
		Account::rate=rate;
	else {
		Account::rate=0;
		cout << "WARNING! You have entered an invalid rate!\n";
	}
}

void Account::ApplyIntrest() {
		intrest = rate * balance;
		NewBalance = intrest + balance;
		cout << "The amount of intrest for the Customer is: $" << intrest << " and the account balance is: $" << NewBalance << ".\n";
}	

Customer& getCustomer(int n) {
	return myCustomer[n];
}

    void operator += (Account& a) {
        setBalance(balance + a.balance());
    }

    void operator -= (Account& a) {
        setBalance(balance - a.balance());
    }

    void operator ++ (int n) {
		Customer::balance(Customer::savings + Customer::checking);
    }


};
#endif





Date Header File

#ifndef DATE_H
#define DATE_H

#include "Customer.h"
//Date class
class Date
{
private:
   string month;
   int day;
   int year;
public:
   void setDate(string month, int day, int year)
   {
     this->month = month;
     this->day = day;
     this->year = year;
   }
   Date(string month, int day, int year)
   {
      setDate(month, day, year);
   }
   Date()
   {
      setDate("January", 1, 1900);
   }
   string getMonth() { return month; }
   int getDay() { return day; }
   int getYear() { return year; }

}

#endif



Errors

1>------ Build started: Project: Test1, Configuration: Debug Win32 ------
1> Test1.cpp
\account.h(35): error C2535: 'Account::Account(void)' : member function already defined or declared
1> \account.h(18) : see declaration of 'Account::Account'
\account.h(42): error C2535: 'Account::Account(std::string,int,double,double)' : member function already defined or declared
1> \account.h(19) : see declaration of 'Account::Account'
\account.h(97): error C2064: term does not evaluate to a function taking 0 arguments
\account.h(101): error C2064: term does not evaluate to a function taking 0 arguments
\account.h(105): error C2597: illegal reference to non-static member 'Customer::balance'
\account.h(105): error C2597: illegal reference to non-static member 'Customer::savings'
\account.h(105): error C3867: 'Customer::savings': function call missing argument list; use '&Customer::savings' to create a pointer to member
\account.h(105): error C2597: illegal reference to non-static member 'Customer::checking'
\account.h(105): error C3867: 'Customer::checking': function call missing argument list; use '&Customer::checking' to create a pointer to member
\account.h(105): error C2568: '+' : unable to resolve function overload
1> unable to recover from previous error(s); stopping compilation

Is This A Good Question/Topic? 0
  • +

Replies To: Assignment Error Help

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 5954
  • View blog
  • Posts: 23,215
  • Joined: 23-August 08

Re: Assignment Error Help

Posted 15 February 2010 - 05:39 PM

Account(string, int, double, double) {
                void setType(string);
                void setNumber(int);
                void setBalance(double);
                void setRate(double);

                string getType();
                int getNumber();
                double getBalance();
                double getRate();

                void valid_Rate(double);
                void ApplyInterest();
        };


Huh? Why all the function declarations inside the overloaded constructor?
Was This Post Helpful? 0
  • +
  • -

#3 tarheelfan_08  Icon User is offline

  • D.I.C Regular

Reputation: -2
  • View blog
  • Posts: 256
  • Joined: 24-January 10

Re: Assignment Error Help

Posted 15 February 2010 - 06:14 PM

Its how my teacher had it set up for an example...and he told us to do it the exact same.... and that is how he did it! Am I wrong or do I need to do something different or what?
Was This Post Helpful? 0
  • +
  • -

#4 xxStardaSxx  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 7
  • Joined: 14-February 10

Re: Assignment Error Help

Posted 15 February 2010 - 06:26 PM

hi tarheelfan_08. The first few erros might have some to do with the second declaration of the constructor of the account class.When you made the second declaration, at it's end, will put a open braces :
Account(string, int, double, double) {


So the compiler consider the folowing code :
                void setType(string);
                void setNumber(int);
                void setBalance(double);
                void setRate(double);

                string getType();
                int getNumber();
                double getBalance();
                double getRate();

                void valid_Rate(double);
                void ApplyInterest();
        };



as an implementation of the constructor.Since the other declaration, and the only one considered by the compiler, of the constructor don't match with the "implementation", the compiler issues the first couple of erros. Remove the braces and it should be fine.

ps: i got my compiler to work eight now.You have actualy about 30 erros in this code.Most of them due to misstyping( writing wrongly the name of functions )
be aware that c++ is a case-sensitive language, so getSSN is different thatn getssn.You have lots of this in your code

ps2:many others erros are due to the use of the scope resolution operator (::).It is used to reference global variables or static members of classes.But you're using it to reference non-static member.Because of that the compiler is issuing erros.Insted of Customer::getSavings() use a instance of the Customer class ( i.i myCustomer) : myCustomer.getSavings()( it seems that in the overload declarations this is not working.But in other parts of the code it will)
Most of the erros are easily to be corrected, so review you code carefully, and post any more doubts that may appear.

This post has been edited by xxStardaSxx: 15 February 2010 - 07:18 PM

Was This Post Helpful? 1
  • +
  • -

#5 tarheelfan_08  Icon User is offline

  • D.I.C Regular

Reputation: -2
  • View blog
  • Posts: 256
  • Joined: 24-January 10

Re: Assignment Error Help

Posted 15 February 2010 - 07:20 PM

I made those changes and I got a lot more errors.

#ifndef ACCOUNT_H
#define ACCOUNT_H

#include "Customer.h"

//Account Class
class Account {
private:
        Customer myCustomer[2];
        string type;
        int number;
    double balance;
    double rate;
        double intrest;
        double NewBalance;

public:
        Account(); // Constructor
        Account(string, int, double, double); 
                void setType(string);
                void setNumber(int);
                void setBalance(double);
                void setRate(double);

                string getType();
                int getNumber();
                double getBalance();
                double getRate();

                void valid_Rate(double);
                void ApplyInterest();
        
//-----------------------------------------------------------------------------
//class definition
        Account::Account() {
                type = " ";
                number = 0;
                balance = 0;
                rate = 0;
        }

        Account::Account(string type, int number, double balance, double rate) {
                Account::type = type;
                Account::number = number;
                Account::balance = balance;
                valid_rate(rate);
                }
void Account::setType(string type) {
    Account::type = type;
}

void Account::setNumber(int number) {
    Account::number = number;
}

void Account::setBalance(double balance) {
    Account::balance = balance;
}

void Account::setRate(double rate) {
        valid_rate(rate);
}

string Account::getType() {
    return type;
}
int Account::getNumber() {
    return number;
}
double Account::getBalance() {
    return balance;
}
double Account::getRate() {
    return rate;
}

void Account::valid_rate(double rate) {
        if (rate >=.01 && rate <= .1)
                Account::rate=rate;
        else {
                Account::rate=0;
                cout << "WARNING! You have entered an invalid rate!\n";
        }
}

void Account::ApplyIntrest() {
                intrest = rate * balance;
                NewBalance = intrest + balance;
                cout << "The amount of intrest for the Customer is: $" << intrest << " and the account balance is: $" << NewBalance << ".\n";
}       

Customer& getCustomer(int n) {
        return myCustomer[n];
}

    void operator += (Account& a) {
        setBalance(balance + a.balance());
    }

    void operator -= (Account& a) {
        setBalance(balance - a.balance());
    }

    void operator ++ (int n) {
                Customer::balance(getSavings() + getChecking());
    }


};
#endif



1>------ Build started: Project: Test1, Configuration: Debug Win32 ------
1> Test1.cpp
1>\account.h(35): error C2535: 'Account::Account(void)' : member function already defined or declared
1> \account.h(18) : see declaration of 'Account::Account'
1>\account.h(42): error C2535: 'Account::Account(std::string,int,double,double)' : member function already defined or declared
1> \account.h(19) : see declaration of 'Account::Account'
1>\account.h(48): error C2535: 'void Account::setType(std::string)' : member function already defined or declared
1> \account.h(20) : see declaration of 'Account::setType'
1>\account.h(52): error C2535: 'void Account::setNumber(int)' : member function already defined or declared
1> \account.h(21) : see declaration of 'Account::setNumber'
1>\account.h(56): error C2535: 'void Account::setBalance(double)' : member function already defined or declared
1> \account.h(22) : see declaration of 'Account::setBalance'
1>\account.h(60): error C2535: 'void Account::setRate(double)' : member function already defined or declared
1> \account.h(23) : see declaration of 'Account::setRate'
1>\account.h(64): error C2535: 'std::string Account::getType(void)' : member function already defined or declared
1> \account.h(25) : see declaration of 'Account::getType'
1>\account.h(67): error C2535: 'int Account::getNumber(void)' : member function already defined or declared
1> \account.h(26) : see declaration of 'Account::getNumber'
1>\account.h(70): error C2535: 'double Account::getBalance(void)' : member function already defined or declared
1> \account.h(27) : see declaration of 'Account::getBalance'
1>\account.h(73): error C2535: 'double Account::getRate(void)' : member function already defined or declared
1> \account.h(28) : see declaration of 'Account::getRate'
1>\account.h(97): error C2064: term does not evaluate to a function taking 0 arguments
1>\account.h(101): error C2064: term does not evaluate to a function taking 0 arguments
1>\account.h(105): error C2597: illegal reference to non-static member 'Customer::balance'
1>\account.h(105): error C3861: 'getSavings': identifier not found
1>\account.h(105): error C3861: 'getChecking': identifier not found
1>\test1.cpp(5): error C2143: syntax error : missing ';' before 'using'
1>\test1.cpp(28): error C2039: 'getDate' : is not a member of 'Account'
1> \account.h(7) : see declaration of 'Account'
1>\test1.cpp(28): error C2228: left of '.setDate' must have class/struct/union
1>\test1.cpp(40): error C2660: 'Account::getRate' : function does not take 1 arguments
1>\test1.cpp(40): error C2228: left of '.setRate' must have class/struct/union
1>\test1.cpp(51): error C2676: binary '[' : 'Account' does not define this operator or a conversion to a type acceptable to the predefined operator
1>\test1.cpp(51): error C2228: left of '.displayCustomer' must have class/struct/union
1>\test1.cpp(56): error C2676: binary '[' : 'Account' does not define this operator or a conversion to a type acceptable to the predefined operator
1>\test1.cpp(56): error C2228: left of '.ApplyIntrest' must have class/struct/union
1>\test1.cpp(62): error C2676: binary '[' : 'Account' does not define this operator or a conversion to a type acceptable to the predefined operator
1>\test1.cpp(62): error C2228: left of '.displayCustomer' must have class/struct/union
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Was This Post Helpful? 0
  • +
  • -

#6 xxStardaSxx  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 7
  • Joined: 14-February 10

Re: Assignment Error Help

Posted 15 February 2010 - 07:52 PM

yes i know.I got the same thing.
But the compiler is only showing errors that were there but it didn't caucht before.One thing that are causing many errors is the misplaced "};" that marks the end of the class declaration.It's located in the final of the file, but in this way the sapared implementation is placed in the body of the declaration.So when you have Account::Account() or Account::setType() and then the implementation code, the compiler is treating it as a overloading of those function which were previosly declared.So move the "};" ( and of the declaration of the class ip, before any implamentation.By doing this, you'll find even more errors that the compiler were not catching before.Many of then are result of misstyping( typing wrongly the name of a function or a data member ), or undeclared variables that you're trying to use, as in the following code :
void Account::ApplyIntrest() {
                intrest = rate * balance;
                NewBalance = intrest + balance;
                cout << "The amount of intrest for the Customer is: $" << intrest << " and the account balance is: $" << NewBalance << ".\n";
}   


declare this variables ( NewBalance, intrest ) before using it.
Some other errors are due the attempt of access private data members from out of the scope of the class.Such operations are not allowed.You must in this case use the access functions of your class.

and finally there are some erroes in the operator overloading that i can't help you, because of my lack of knowledge in this subject.Maybe other can help you with this.

if any other error persist, other than in the par of operator overloading, post and i'll help you.
Was This Post Helpful? 0
  • +
  • -

#7 tarheelfan_08  Icon User is offline

  • D.I.C Regular

Reputation: -2
  • View blog
  • Posts: 256
  • Joined: 24-January 10

Re: Assignment Error Help

Posted 15 February 2010 - 07:58 PM

#ifndef ACCOUNT_H
#define ACCOUNT_H

#include "Customer.h"

//Account Class
class Account {
private:
        Customer myCustomer[2];
        string type;
        int number;
    double balance;
    double rate;
        double intrest;
        double NewBalance;

public:
        Account(); // Constructor
        Account(string, int, double, double) {
                void setType(string);
                void setNumber(int);
                void setBalance(double);
                void setRate(double);

                string getType();
                int getNumber();
                double getBalance();
                double getRate();

                void valid_rate(double);
                void ApplyInterest();
        
//-----------------------------------------------------------------------------
//class definition
        Account::Account() {
                type = " ";
                number = 0;
                balance = 0;
                rate = 0;
        }

        Account::Account(string type, int number, double balance, double rate) {
                Account::type = type;
                Account::number = number;
                Account::balance = balance;
                valid_rate(rate);
                }
		};
void Account::setType(string type) {
    Account::type = type;
}

void Account::setNumber(int number) {
    Account::number = number;
}

void Account::setBalance(double balance) {
    Account::balance = balance;
}

void Account::setRate(double rate) {
        valid_rate(rate);
}

string Account::getType() {
    return type;
}
int Account::getNumber() {
    return number;
}
double Account::getBalance() {
    return balance;
}
double Account::getRate() {
    return rate;
}

void Account::valid_rate(double rate) {
        if (rate >=.01 && rate <= .1)
                Account::rate=rate;
        else {
                Account::rate=0;
                cout << "WARNING! You have entered an invalid rate!\n";
        }
}

void Account::ApplyInterest() {
                intrest = rate * balance;
                NewBalance = intrest + balance;
                cout << "The amount of intrest for the Customer is: $" << intrest << " and the account balance is: $" << NewBalance << ".\n";
}       

Customer& getCustomer(int n) {
        return myCustomer[n];
}

    void operator += (Account& a) {
        setBalance(balance + a.balance());
    }

    void operator -= (Account& a) {
        setBalance(balance - a.balance());
    }

    void operator ++ (int n) {
                Customer::balance(Customer::savings + Customer::checking);
    }


};
#endif




1>------ Build started: Project: Test1, Configuration: Debug Win32 ------
1> Test1.cpp
1>\account.h(35): error C2143: syntax error : missing ';' before '{'
1>\account.h(42): error C2275: 'std::string' : illegal use of this type as an expression
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\xstring(2054) : see declaration of 'std::string'
1>\account.h(42): error C2146: syntax error : missing ')' before identifier 'type'
1>\account.h(42): error C2059: syntax error : ')'
1>\account.h(42): error C2143: syntax error : missing ';' before '{'
1>\account.h(98): error C2064: term does not evaluate to a function taking 0 arguments
1>\account.h(102): error C2064: term does not evaluate to a function taking 0 arguments
1>\account.h(106): error C2597: illegal reference to non-static member 'Customer::balance'
1>\account.h(106): error C2597: illegal reference to non-static member 'Customer::savings'
1>\account.h(106): error C3867: 'Customer::savings': function call missing argument list; use '&Customer::savings' to create a pointer to member
1>\account.h(106): error C2597: illegal reference to non-static member 'Customer::checking'
1>\account.h(106): error C3867: 'Customer::checking': function call missing argument list; use '&Customer::checking' to create a pointer to member
1>\account.h(106): error C2568: '+' : unable to resolve function overload
1> unable to recover from previous error(s); stopping compilation
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Was This Post Helpful? 0
  • +
  • -

#8 xxStardaSxx  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 7
  • Joined: 14-February 10

Re: Assignment Error Help

Posted 15 February 2010 - 08:46 PM

OK.You remove a lot of errors of misstyping.I got then after a few changes 18 errors a after other changes i manage to get down to 10 errors.
i will explain the changes for you. When a i said to move the and of the declaration up, before any implementation, it included the constructor.So no worry i just moved it up before the implementation of the constructors.You see, when you choose to separate your declaration of the class and its functions and their implementations, you must declare all of their member functions, end the class declaration with };, and only then write the implementation.

The other changes that i did were in this piece of code :
void operator += (Account& a) {
        setBalance(balance + a.balance());
    }

    void operator -= (Account& a) {
        setBalance(balance - a.balance());
    }



you're trying to call functions and data members of Account but not specified any instance of this class to the compiler.And more, as i said before, balance is a private data member and can't be accessed out of the scope of the class Account.To solve this last problem you could :
1_ make balance a public data member
2_use access function(which you already created - getBalance)

the first option is not a good choice from the software engeneering stand point, because it can allow one to corrupt that data.Only the Account class should have access to the balance.So i used the secont option.

Now the other problem of not specificate a instance of the class Account can be easily solved.In the overloading function you request the reference to a object of the class Account(instance) as a parameter. So i just used its access function to the balance data member as follows:
void operator += (Account& a) {
        a.setBalance(a.getBalance()+ a.getBalance());
    }

    void operator -= (Account& a) {
        a.setBalance(a.getBalance() - a.getBalance());
    }



An finally there were erros with the function getCutomer.It was not a part of the class Account, but it was trying to access it private data member myCustomer.So i just add it to the declaration of the class and put Account:: in the implementation as you see in the code.
so the hole code is now like this:
#ifndef ACCOUNT_H
#define ACCOUNT_H

#include "Customer.h"

//Account Class
class Account {
private:
        Customer myCustomer[2];
        string type;
        int number;
    double balance;
    double rate;
        double intrest;
        double NewBalance;

public:
        Account(); // Constructor
        Account(string, int, double, double) ;
                void setType(string);
                void setNumber(int);
                void setBalance(double);
                void setRate(double);

                string getType();
                int getNumber();
                double getBalance();
                double getRate();
                Customer& getCustomer ( int );
                void valid_rate(double);
                void ApplyInterest();
		};       
//-----------------------------------------------------------------------------
//class definition
        Account::Account() {
                type = " ";
                number = 0;
                balance = 0;
                rate = 0;
        }

        Account::Account(string type, int number, double balance, double rate) {
                Account::type = type;
                Account::number = number;
                Account::balance = balance;
                valid_rate(rate);
                }
void Account::setType(string type) {
    Account::type = type;
}

void Account::setNumber(int number) {
    Account::number = number;
}

void Account::setBalance(double balance) {
    Account::balance = balance;
}

void Account::setRate(double rate) {
        valid_rate(rate);
}

string Account::getType() {
    return type;
}
int Account::getNumber() {
    return number;
}
double Account::getBalance() {
    return balance;
}
double Account::getRate() {
    return rate;
}

void Account::valid_rate(double rate) {
        if (rate >=.01 && rate <= .1)
                Account::rate=rate;
        else {
                Account::rate=0;
                cout << "WARNING! You have entered an invalid rate!\n";
        }
}

void Account::ApplyInterest() {
                intrest = rate * balance;
                NewBalance = intrest + balance;
                cout << "The amount of intrest for the Customer is: $" << intrest << " and the account balance is: $" << NewBalance << ".\n";
}       


Customer& Account::getCustomer(int n) {
        return myCustomer[n];
}

    void operator += (Account& a) {
        a.setBalance(a.getBalance()+ a.getBalance());
    }

    void operator -= (Account& a) {
        a.setBalance(a.getBalance() - a.getBalance());
    }
//MOST OF THE LEFT ERRORS ARE HERE--------------------------------------
    void operator ++ (int n, ) {
                Customer::balance(Customer::savings + Customer::checking);
    }

#endif


copy it and replace the old one.
the remaining errors are in the overloading part, and as i said i don't now how to solve them.Maybe someone else can.

sorry for the extense responses :X =P
i hope i could help
Was This Post Helpful? 0
  • +
  • -

#9 tarheelfan_08  Icon User is offline

  • D.I.C Regular

Reputation: -2
  • View blog
  • Posts: 256
  • Joined: 24-January 10

Re: Assignment Error Help

Posted 15 February 2010 - 09:04 PM

Ok thanks, just for everyone else here is the new code and errors!

Changed my code and here it is!

#ifndef ACCOUNT_H
#define ACCOUNT_H

#include "Customer.h"

//Account Class
class Account {
private:
        Customer myCustomer[2];
        string type;
        int number;
    double balance;
    double rate;
        double intrest;
        double NewBalance;

public:
        Account(); // Constructor
        Account(string, int, double, double) ;
                void setType(string);
                void setNumber(int);
                void setBalance(double);
                void setRate(double);

                string getType();
                int getNumber();
                double getBalance();
                double getRate();
                Customer& getCustomer ( int );
                void valid_rate(double);
                void ApplyInterest();
                };       
//-----------------------------------------------------------------------------
//class definition
        Account::Account() {
                type = " ";
                number = 0;
                balance = 0;
                rate = 0;
        }

        Account::Account(string type, int number, double balance, double rate) {
                Account::type = type;
                Account::number = number;
                Account::balance = balance;
                valid_rate(rate);
                }
void Account::setType(string type) {
    Account::type = type;
}

void Account::setNumber(int number) {
    Account::number = number;
}

void Account::setBalance(double balance) {
    Account::balance = balance;
}

void Account::setRate(double rate) {
        valid_rate(rate);
}

string Account::getType() {
    return type;
}
int Account::getNumber() {
    return number;
}
double Account::getBalance() {
    return balance;
}
double Account::getRate() {
    return rate;
}

void Account::valid_rate(double rate) {
        if (rate >=.01 && rate <= .1)
                Account::rate=rate;
        else {
                Account::rate=0;
                cout << "WARNING! You have entered an invalid rate!\n";
        }
}

void Account::ApplyInterest() {
                intrest = rate * balance;
                NewBalance = intrest + balance;
                cout << "The amount of intrest for the Customer is: $" << intrest << " and the account balance is: $" << NewBalance << ".\n";
}       


Customer& Account::getCustomer(int n) {
        return myCustomer[n];
}

    void operator += (Account& a) {
        a.setBalance(a.getBalance()+ a.getBalance());
    }

    void operator -= (Account& a) {
        a.setBalance(a.getBalance() - a.getBalance());
    }
//MOST OF THE LEFT ERRORS ARE HERE--------------------------------------
    void operator ++ (int n, ) {
                Customer::balance(Customer::savings + Customer::checking);
    }

#endif



1>------ Build started: Project: Test1, Configuration: Debug Win32 ------
1> Test1.cpp
1>\account.h(97): error C2805: binary 'operator +=' has too few parameters
1>\account.h(101): error C2805: binary 'operator -=' has too few parameters
1>\account.h(105): error C2059: syntax error : ')'
1>\account.h(105): error C2143: syntax error : missing ')' before '{'
1>\account.h(105): error C2803: 'operator ++' must have at least one formal parameter of class type
1>\account.h(106): error C2597: illegal reference to non-static member 'Customer::balance'
1>\account.h(106): error C2597: illegal reference to non-static member 'Customer::savings'
1>\account.h(106): error C3867: 'Customer::savings': function call missing argument list; use '&Customer::savings' to create a pointer to member
1>\account.h(106): error C2597: illegal reference to non-static member 'Customer::checking'
1>\account.h(106): error C3867: 'Customer::checking': function call missing argument list; use '&Customer::checking' to create a pointer to member
1>\account.h(106): error C2568: '+' : unable to resolve function overload
1> unable to recover from previous error(s); stopping compilation
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Was This Post Helpful? 0
  • +
  • -

#10 xxStardaSxx  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 7
  • Joined: 14-February 10

Re: Assignment Error Help

Posted 15 February 2010 - 09:23 PM

Man, sorry for not helping you more.But it's 2:15 a.m here in Brazil, and i need some sleep.(Lots of late night coding =PP ).
I have the material here to learn the overloading.So if when i get on the computer later, no one have answered you, i will do it.
bye
Was This Post Helpful? 0
  • +
  • -

#11 tarheelfan_08  Icon User is offline

  • D.I.C Regular

Reputation: -2
  • View blog
  • Posts: 256
  • Joined: 24-January 10

Re: Assignment Error Help

Posted 15 February 2010 - 09:25 PM

Ok man, the assignment is due in like 24 hours so I got to get it done asap! So please do help me if nobody else does and thanks for all you have done!
Was This Post Helpful? 0
  • +
  • -

#12 tarheelfan_08  Icon User is offline

  • D.I.C Regular

Reputation: -2
  • View blog
  • Posts: 256
  • Joined: 24-January 10

Re: Assignment Error Help

Posted 15 February 2010 - 09:33 PM

I changed some stuff and here is what I got Please help

#ifndef ACCOUNT_H
#define ACCOUNT_H

#include "Customer.h"

//Account Class
class Account {
private:
        Customer myCustomer[2];
        string type;
        int number;
        double balance;
        double rate;

        double intrest;
        double NewBalance;

public:
        Account(); // Constructor
        Account(string, int, double, double) ;
                void setType(string);
                void setNumber(int);
                void setBalance(double);
                void setRate(double);

                string getType();
                int getNumber();
                double getBalance();
                double getRate();
                Customer& getCustomer ( int );
                void valid_rate(double);
                void ApplyInterest();
                void operator += (Account&);
                void operator -= (Account&);
                void operator ++ (int);
                };      
//-----------------------------------------------------------------------------
//class definition
        Account::Account() {
                type = " ";
                number = 0;
                balance = 0;
                rate = 0;
        }

        Account::Account(string type, int number, double balance, double rate) {
                Account::type = type;
                Account::number = number;
                Account::balance = balance;
                valid_rate(rate);
                }
void Account::setType(string type) {
    Account::type = type;
}

void Account::setNumber(int number) {
    Account::number = number;
}

void Account::setBalance(double balance) {
    Account::balance = balance;
}

void Account::setRate(double rate) {
        valid_rate(rate);
}

string Account::getType() {
    return type;
}
int Account::getNumber() {
    return number;
}
double Account::getBalance() {
    return balance;
}
double Account::getRate() {
    return rate;
}

void Account::valid_rate(double rate) {
        if (rate >=.01 && rate <= .1)
                Account::rate=rate;
        else {
                Account::rate=0;
                cout << "WARNING! You have entered an invalid rate!\n";
        }
}

void Account::ApplyInterest() {
                intrest = rate * balance;
                NewBalance = intrest + balance;
                cout << "The amount of intrest for the Customer is: $" << intrest << " and the account balance is: $" << NewBalance << ".\n";
}      


Customer& Account::getCustomer(int n) {
        return myCustomer[n];
}

void Account::operator += (Account& a) {
        a.setBalance(a.getBalance()+ a.getBalance());
    }
    void Account::operator -= (Account& a) {
        a.setBalance(a.getBalance() - a.getBalance());
    }

    void operator ++ (int n) {
           int temp_savings = Customer::getSavings();
           int temp_checking = Customer::getChecking();
           Account::setBalance(temp_savings  +  temp_checking);
        }

#endif

1>------ Build started: Project: Test1, Configuration: Debug Win32 ------
1> Test1.cpp
1>\account.h(108): error C2803: 'operator ++' must have at least one formal parameter of class type
1>\account.h(109): error C2352: 'Customer::getSavings' : illegal call of non-static member function
1> \customer.h(40) : see declaration of 'Customer::getSavings'
1>\account.h(110): error C2352: 'Customer::getChecking' : illegal call of non-static member function
1> \customer.h(41) : see declaration of 'Customer::getChecking'
1>\account.h(111): error C2352: 'Account::setBalance' : illegal call of non-static member function
1> \account.h(23) : see declaration of 'Account::setBalance'
1>\date.h(32): fatal error C1070: mismatched #if/#endif pair in file '\date.h'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

This post has been edited by tarheelfan_08: 15 February 2010 - 09:53 PM

Was This Post Helpful? 0
  • +
  • -

#13 xxStardaSxx  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 7
  • Joined: 14-February 10

Re: Assignment Error Help

Posted 16 February 2010 - 06:29 AM

Well after i nice sleep here i am again =].
Well i copied your code again and, well, we are much better than before, with only six errors. The first of them that i correct was in the date declaration.You forgot to put ; after the closure brace in the end of the file (declaration and implementation of the class):
DATE.H
   //final part of Date.h
   string getMonth() { return month; }
   int getDay() { return day; }
   int getYear() { return year; }

};//HERE

#endif 



Now there are 4 errors left.Well, observing in more detail your code i understood part of what those overload operators functions were suppose to do.
You were using them to increment the balance data member with a specific value, with the operators += and -=, and to increment some odd thing that didn't figure out, with the operator ++.

So what was causing the errors were three things. First, you didn't declare those functions.Second, they are suppose to alter objects of the type Customer, so they must be place in the Customer file.( and declared there too ). And finally the logic behind the overloading wasn't quite right.You see, the operators += and -= take two operands one on the left side and other in the right side.The one in the left would be, in this case, the object of the type Customer, and the on in the right side would be the value that you want to increment the Customer Balance.Using this logic i got the following codes

So in the declaration of the class Customer you must do like this :
  	void operator +=( double );
	void operator -=( double );



the implementation would be :
void Customer::operator += ( double dValue ) {
        setBalance( getBalance()+ dValue );
}
void Customer::operator -= ( double dValue ) {
        setBalance( getBalance() - dValue );
}



Now those two functions are part of the Customer class and, therefor all of its instances.So we are at the class scope and i could access its private members directly, or, and this should be your choice, i could use their access functions.So no need Customer::getBalance, this acctualy is wrong( if you don't understand i can explain later).So, because i'm in the class scope i just call the functions by their names and they will alter that instance balance data member. if want to do somechanges to validate value, feel free to do it, but remmember of this logic that i ( hope ) explain(ed).

well now regarding the operator ++, i didn't understood its purpose, maybe something to do with my poor english, but its declaration would be :
void operator++ ();



and implementation :
void Customer::operator ++ () {
     setBalance(getSavings()  +  getChecking());
 }



there is also the prefix incrementation, but this one i couldn't do it;

An finally my compiler has issued some warnings.All of them were conserning the convertion of types between Double to int, in your set functions to the data members savings, balance and checking. In its declarations i just changed the type of the argument to double, because those data members are of the type double, and down casting like this can result in data loss.So i changed in the declaration and down in the implementation, and also the return type of the access functions to those same data members that were set to int, and would result in the same problem of losing data.Edited:actually you diD declared those data members as int.Because you're dealing with money i thought it was more aproppriated to change them to double, that can hold more information.

so the final and working code, because i tested :], was like this :
DON'T FORGET TO DO THE FIRST CHANGE I SAID IN THE DATE.H FILE!!!!!
#ifndef CUSTOMER_H
#define CUSTOMER_H

#include <iostream>
#include <fstream>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <string>
#include <cstdlib>
#include <sstream>
using namespace std;

//Customer Class
class Customer {
private:
    string name;  //name of customer
    string ssn; // social security number
    string address;  // address
    int birthDate;      //birth date
    double savings;  // savings account balance
    double checking;  // checking account balance
    double balance;    // Consoldated Balance

public:
    Customer(); //constructor
    Customer(string, string, string, int ,int, int, int);
    void setName(string);
    void setSSN(string);
    void setAddress(string);
    void setBirthDate(int);
    void setSavings(double);
    void setChecking(double);
        void setBalance(double);
	
	void operator +=( double );
	void operator -=( double );
	void operator ++ ();

    string getName();
    string getSSN();
    string getAddress();
    int getBirthDate();
    double getSavings();
    double getChecking();
    double getBalance();

        void displayCustomer();
        string string_displayCustomer();


};


//-----------------------------------------------------------------------------
//class definition
Customer::Customer() {
    name = " ";
    ssn = " ";
    address = " ";
    birthDate = 0;
    savings = 0;
        checking = 0;
        balance = 0;
}

Customer::Customer(string name, string ssn, string address, int birthDate, int savings, int checking, int balance) {
    Customer::name =  name;
    Customer::ssn = ssn;
    Customer::address = address;
    Customer::birthDate = birthDate;
    Customer::savings = savings;
    Customer::checking = checking;
        Customer::balance = balance;
}

void Customer::setName(string name) {
    Customer::name = name;
}

void Customer::setSSN(string ssn) {
    Customer::ssn = ssn;
}

void Customer::setAddress(string address) {
    Customer::address = address;
}

void Customer::setBirthDate(int birthDate) {
    Customer::birthDate = birthDate;
}

void Customer::setSavings(double savings) {
    Customer::savings = savings;
}

void Customer::setChecking(double checking) {
    Customer::checking = checking;
}

void Customer::setBalance(double balance) {
        Customer::balance = balance;
}



string Customer::getName() {
    return name;
}

string Customer::getSSN() {
    return ssn;
}

string Customer::getAddress() {
    return address;
}

int Customer::getBirthDate() {
    return birthDate;
}

double Customer::getSavings() {
    return savings;
}

double Customer::getChecking() {
    return checking;
}

double Customer::getBalance() {
        return balance;

}

void Customer::displayCustomer() {
    cout << "The current customer is " << name << ", their address is " << address << ", and their Social Security Number is "
                << ssn << ".  "  << name << "'s Saving Account Ballance is:" << savings << ".  The Checking Account Balance is:" << checking << ".\n";
        cout << "The consolidated balance is: $" << balance << ".\n";
}

string Customer::string_displayCustomer() {
        stringstream buf;
        cout << "The current customer is " << name << ", their address is " << address << ", and their Social Security Number is "
        << ssn << ".  "  << name << "'s Saving Account Ballance is:" << savings << ".  The Checking Account Balance is:" << checking << ".\n";
        cout << "The consolidated balance is: $" << balance << ".\n";
    return buf.str();
}
void Customer::operator += ( double dValue ) {
        setBalance( getBalance()+ dValue );
		//return this;
    }
void Customer::operator -= ( double dValue ) {
        setBalance( getBalance() - dValue );
		//return this;
    }

void Customer::operator ++ () {
       
      setBalance(getSavings()  +  getChecking());
 }

#endif




Well its finaly working.I have some more tips to give you, but i'll wait you to respond me and confirm that the code is running.
i hope i could help you

This post has been edited by xxStardaSxx: 16 February 2010 - 06:43 AM

Was This Post Helpful? 0
  • +
  • -

#14 tarheelfan_08  Icon User is offline

  • D.I.C Regular

Reputation: -2
  • View blog
  • Posts: 256
  • Joined: 24-January 10

Re: Assignment Error Help

Posted 16 February 2010 - 08:44 PM

Dude I tired this stuff and it did not work! But I think I have messed up some where....here is my code!

Date.h

#ifndef DATE_H
#define DATE_H

#include "Customer.h"

//Date class
class Date
{
private:
   string month;
   int day;
   int year;
public:
   void setDate(string month, int day, int year)
   {
     this->month = month;
     this->day = day;
     this->year = year;
   }
   Date(string month, int day, int year)
   {
      setDate(month, day, year);
   }
   Date()
   {
      setDate("January", 1, 1900);
   }
   string getMonth() { return month; }
   int getDay() { return day; }
   int getYear() { return year; }

};


#endif



Customer.h
#ifndef CUSTOMER_H
#define CUSTOMER_H

#include <iostream>
#include <fstream>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <string>
#include <cstdlib>
#include <sstream>
using namespace std;

//Customer Class
class Customer {
private:
    string name;  //name of customer
    string ssn; // social security number
    string address;  // address
    int birthDate;      //birth date
    double savings;  // savings account balance
    double checking;  // checking account balance
    double balance;    // Consoldated Balance

public:
    Customer(); //constructor
    Customer(string, string, string, int ,int, int, int);
    void setName(string);
    void setSSN(string);
    void setAddress(string);
    void setBirthDate(int);
    void setSavings(double);
    void setChecking(double);
        void setBalance(double);
        
        void operator +=( double );
        void operator -=( double );
        void operator ++ ();

    string getName();
    string getSSN();
    string getAddress();
    int getBirthDate();
    double getSavings();
    double getChecking();
    double getBalance();

        void displayCustomer();
        string string_displayCustomer();


};


//-----------------------------------------------------------------------------
//class definition
Customer::Customer() {
    name = " ";
    ssn = " ";
    address = " ";
    birthDate = 0;
    savings = 0;
        checking = 0;
        balance = 0;
}

Customer::Customer(string name, string ssn, string address, int birthDate, int savings, int checking, int balance) {
    Customer::name =  name;
    Customer::ssn = ssn;
    Customer::address = address;
    Customer::birthDate = birthDate;
    Customer::savings = savings;
    Customer::checking = checking;
        Customer::balance = balance;
}

void Customer::setName(string name) {
    Customer::name = name;
}

void Customer::setSSN(string ssn) {
    Customer::ssn = ssn;
}

void Customer::setAddress(string address) {
    Customer::address = address;
}

void Customer::setBirthDate(int birthDate) {
    Customer::birthDate = birthDate;
}

void Customer::setSavings(double savings) {
    Customer::savings = savings;
}

void Customer::setChecking(double checking) {
    Customer::checking = checking;
}

void Customer::setBalance(double balance) {
        Customer::balance = balance;
}



string Customer::getName() {
    return name;
}

string Customer::getSSN() {
    return ssn;
}

string Customer::getAddress() {
    return address;
}

int Customer::getBirthDate() {
    return birthDate;
}

double Customer::getSavings() {
    return savings;
}

double Customer::getChecking() {
    return checking;
}

double Customer::getBalance() {
        return balance;

}

void Customer::displayCustomer() {
    cout << "The current customer is " << name << ", their address is " << address << ", and their Social Security Number is "
                << ssn << ".  "  << name << "'s Saving Account Ballance is:" << savings << ".  The Checking Account Balance is:" << checking << ".\n";
        cout << "The consolidated balance is: $" << balance << ".\n";
}

string Customer::string_displayCustomer() {
        stringstream buf;
        cout << "The current customer is " << name << ", their address is " << address << ", and their Social Security Number is "
        << ssn << ".  "  << name << "'s Saving Account Ballance is:" << savings << ".  The Checking Account Balance is:" << checking << ".\n";
        cout << "The consolidated balance is: $" << balance << ".\n";
    return buf.str();
}


 void operator +=( double );
 void operator -=( double );

void Customer::operator += ( double dValue ) {
        setBalance( getBalance()+ dValue );
}
void Customer::operator -= ( double dValue ) {
        setBalance( getBalance() - dValue );
}

#ifndef CUSTOMER_H
#define CUSTOMER_H

#include <iostream>
#include <fstream>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <string>
#include <cstdlib>
#include <sstream>
using namespace std;

//Customer Class
class Customer {
private:
    string name;  //name of customer
    string ssn; // social security number
    string address;  // address
    int birthDate;      //birth date
    double savings;  // savings account balance
    double checking;  // checking account balance
    double balance;    // Consoldated Balance

public:
    Customer(); //constructor
    Customer(string, string, string, int ,int, int, int);
    void setName(string);
    void setSSN(string);
    void setAddress(string);
    void setBirthDate(int);
    void setSavings(double);
    void setChecking(double);
        void setBalance(double);
        
        void operator +=( double );
        void operator -=( double );
        void operator ++ ();

    string getName();
    string getSSN();
    string getAddress();
    int getBirthDate();
    double getSavings();
    double getChecking();
    double getBalance();

        void displayCustomer();
        string string_displayCustomer();


};


//-----------------------------------------------------------------------------
//class definition
Customer::Customer() {
    name = " ";
    ssn = " ";
    address = " ";
    birthDate = 0;
    savings = 0;
        checking = 0;
        balance = 0;
}

Customer::Customer(string name, string ssn, string address, int birthDate, int savings, int checking, int balance) {
    Customer::name =  name;
    Customer::ssn = ssn;
    Customer::address = address;
    Customer::birthDate = birthDate;
    Customer::savings = savings;
    Customer::checking = checking;
        Customer::balance = balance;
}

void Customer::setName(string name) {
    Customer::name = name;
}

void Customer::setSSN(string ssn) {
    Customer::ssn = ssn;
}

void Customer::setAddress(string address) {
    Customer::address = address;
}

void Customer::setBirthDate(int birthDate) {
    Customer::birthDate = birthDate;
}

void Customer::setSavings(double savings) {
    Customer::savings = savings;
}

void Customer::setChecking(double checking) {
    Customer::checking = checking;
}

void Customer::setBalance(double balance) {
        Customer::balance = balance;
}



string Customer::getName() {
    return name;
}

string Customer::getSSN() {
    return ssn;
}

string Customer::getAddress() {
    return address;
}

int Customer::getBirthDate() {
    return birthDate;
}

double Customer::getSavings() {
    return savings;
}

double Customer::getChecking() {
    return checking;
}

double Customer::getBalance() {
        return balance;

}

void Customer::displayCustomer() {
    cout << "The current customer is " << name << ", their address is " << address << ", and their Social Security Number is "
                << ssn << ".  "  << name << "'s Saving Account Ballance is:" << savings << ".  The Checking Account Balance is:" << checking << ".\n";
        cout << "The consolidated balance is: $" << balance << ".\n";
}

string Customer::string_displayCustomer() {
        stringstream buf;
        cout << "The current customer is " << name << ", their address is " << address << ", and their Social Security Number is "
        << ssn << ".  "  << name << "'s Saving Account Ballance is:" << savings << ".  The Checking Account Balance is:" << checking << ".\n";
        cout << "The consolidated balance is: $" << balance << ".\n";
    return buf.str();
}
void Customer::operator += ( double dValue ) {
        setBalance( getBalance()+ dValue );
                //return this;
    }
void Customer::operator -= ( double dValue ) {
        setBalance( getBalance() - dValue );
                //return this;
    }

void Customer::operator ++ () {
       
      setBalance(getSavings()  +  getChecking());
 }

#endif

void operator++ ();
void Customer::operator ++ () {
     setBalance(getSavings()  +  getChecking());
 }


#endif



account.h
#ifndef ACCOUNT_H
#define ACCOUNT_H

#include "Customer.h"


//Account Class
class Account {
private:
        Customer myCustomer[2];
        static string type;
        static int number;
        static double balance;
        static double rate;

        double intrest;
        double NewBalance;

public:
        Account(); // Constructor
        Account(string, int, double, double) ;
                static void setType(string);
				static void setNumber(int);
				static void setBalance(double);
				static void setRate(double); 

                string getType();
                int getNumber();
                double getBalance();
                double getRate();
                Customer& getCustomer ( int );
                static void valid_rate(double);
                void ApplyInterest();
                void operator += (Account&);
                void operator -= (Account&);
                void operator ++ (int);
                };       
//-----------------------------------------------------------------------------
//class definition
        Account::Account() {
                type = " ";
                number = 0;
                balance = 0;
                rate = 0;
        }

        Account::Account(string type, int number, double balance, double rate) {
                Account::type = type;
                Account::number = number;
                Account::balance = balance;
                valid_rate(rate);
                }
void Account::setType(string type) {
    Account::type = type;
}

void Account::setNumber(int number) {
    Account::number = number;
}

void Account::setBalance(double balance) {
    Account::balance = balance;
}

void Account::setRate(double rate) {
        valid_rate(rate);
}

string Account::getType() {
    return type;
}
int Account::getNumber() {
    return number;
}
double Account::getBalance() {
    return balance;
}
double Account::getRate() {
    return rate;
}

void Account::valid_rate(double rate) {
        if (rate >=.01 && rate <= .1)
                Account::rate=rate;
        else {
                Account::rate=0;
                cout << "WARNING! You have entered an invalid rate!\n";
        }
}

void Account::ApplyInterest() {
                intrest = rate * balance;
                NewBalance = intrest + balance;
                cout << "The amount of intrest for the Customer is: $" << intrest << " and the account balance is: $" << NewBalance << ".\n";
}       


Customer& Account::getCustomer(int n) {
        return myCustomer[n];
}

	void operator +=( double );
	void Customer::operator += ( double dValue ) {
        setBalance( getBalance()+ dValue );
}

    void operator -=( double );
	void Customer::operator -= ( double dValue ) {
        setBalance( getBalance() - dValue );
}

    void operator++ ();

           int temp_savings = customer.getSavings();
           int temp_checking = customer.getChecking();
           Account::setBalance(temp_savings  +  temp_checking);
        }

#endif



Main()
#include "Account.h"
#include "Customer.h"
#include "Date.h"

using namespace std;

int main() {
    int tempInt;
    string tempString;
    Account myAccount, balance;


    for (int i = 0; i<2; i++) {
        cout << "Enter the Name of the Customer: ";
        cin >> tempString;
        myAccount.getCustomer(i).setName(tempString);

        cout << "Enter the Social Security Number of the Customer: ";
        cin >> tempString;
        myAccount.getCustomer(i).setSSN(tempString);

        cout << "Enter the Address of the Customer: ";
        Customer& myCust = myAccount.getCustomer(1);
		myCust.setAddress(tempString);

        cout << "Enter the Birth Date of the Customer: ";
        cin >> tempInt;
       myDate.setDate(tempString);

        cout << "Enter the Savings Account Balance of the Customer: ";
        cin >> tempInt;
       myAccount.getCustomer(i).setSavings(tempInt);

        cout << "Enter the Checking Account Balance of the Customer: ";
        cin >> tempInt;
       myAccount.getCustomer(i).setChecking(tempInt);

	   cout << "Enter the Intrest Rate of the Customer: ";
        cin >> tempInt;
       myAccount.getRate(i).setRate(tempInt);





        cout << "__________________________________________________________\n"<< endl;
    }

	//Reads the Customers
    for(int x=0; x<2; x++) {
        myAccount[x].displayCustomer();
    }

	//Reads the Customers
    for(int x=0; x<2; x++) {
        myAccount[x].ApplyIntrest();
    }


	//Reads the Customers
    for(int x=0; x<2; x++) {
        myAccount[x].displayCustomer();
    }


    return 0;
}


This post has been edited by tarheelfan_08: 16 February 2010 - 08:49 PM

Was This Post Helpful? 0
  • +
  • -

#15 tarheelfan_08  Icon User is offline

  • D.I.C Regular

Reputation: -2
  • View blog
  • Posts: 256
  • Joined: 24-January 10

Re: Assignment Error Help

Posted 16 February 2010 - 08:50 PM

Here are my new errors!

1>------ Build started: Project: Test1, Configuration: Debug Win32 ------
1> Test1.cpp
1>\customer.h(151): error C2803: 'operator +=' must have at least one formal parameter of class type
1>\customer.h(151): error C2805: binary 'operator +=' has too few parameters
1>\customer.h(152): error C2803: 'operator -=' must have at least one formal parameter of class type
1>\customer.h(152): error C2805: binary 'operator -=' has too few parameters
1>\customer.h(325): error C2809: 'operator ++' has no formal parameters
1>\account.h(108): error C2803: 'operator ++' must have at least one formal parameter of class type
1>\account.h(109): error C2352: 'Customer::getSavings' : illegal call of non-static member function
1> \customer.h(44) : see declaration of 'Customer::getSavings'
1>\account.h(110): error C2352: 'Customer::getChecking' : illegal call of non-static member function
1> \customer.h(45) : see declaration of 'Customer::getChecking'
1>\account.h(111): error C2352: 'Account::setBalance' : illegal call of non-static member function
1> \account.h(23) : see declaration of 'Account::setBalance'
1>\test1.cpp(28): error C2065: 'myDate' : undeclared identifier
1>\test1.cpp(28): error C2228: left of '.setDate' must have class/struct/union
1> type is ''unknown-type''
1>\test1.cpp(40): error C2660: 'Account::getRate' : function does not take 1 arguments
1>\test1.cpp(40): error C2228: left of '.setRate' must have class/struct/union
1>\test1.cpp(51): error C2676: binary '[' : 'Account' does not define this operator or a conversion to a type acceptable to the predefined operator
1>\test1.cpp(51): error C2228: left of '.displayCustomer' must have class/struct/union
1>\test1.cpp(56): error C2676: binary '[' : 'Account' does not define this operator or a conversion to a type acceptable to the predefined operator
1>\test1.cpp(56): error C2228: left of '.ApplyIntrest' must have class/struct/union
1>\test1.cpp(62): error C2676: binary '[' : 'Account' does not define this operator or a conversion to a type acceptable to the predefined operator
1>\test1.cpp(62): error C2228: left of '.displayCustomer' must have class/struct/union
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Was This Post Helpful? 0
  • +
  • -

  • (3 Pages)
  • +
  • 1
  • 2
  • 3