Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
C++
#ifndef ACCOUNT_H
#define ACCOUNT_H
#include <iostream>
#include <string>
using namespace std;

class Account
{
private:
	int actNumber;
	double balance;
	
public:
	virtual void printBal() = 0;
	Account();// defalut constructor
	Account(int actnm, double bal); //overloaded constructor
	void setBal(double bal);
	void setActno(int actnm);
	double getBal();
	int getActnum();
	

};
#endif



#include "Customer.h"

int main()
{
	Customer Nibras;
	
	
	double money;

	
	nibras.setCust(658452,500,.03,10,"adam","Cicero",312952);
	adam.print();
	cout << "Enter the amount to withdrawl :" ;
	cin >> money;
	adam.withdrawl(money);
	adam.print();
	adam.deposit(700);
	adam.print();
	cout << "After interest and fees" << endl;
	adam.mymoney.calcIntFee();
	adam.print();
	
	return 0;
}

#include "Customer.h"


double Customer::withdrawl(double amnt)
{
	double amt;
	amt = mymoney.getBal() - amnt;
	mymoney.setBal(amt);
	return amt;
}
double Customer::deposit(double amnt)
{
	double amt;
	amt = mymoney.getBal() + amnt;
	mymoney.setBal(amt);
	return amt;
}
Customer::Customer()
{
}
Customer::Customer(int actnm, double bal, double ints, double fee, string name, string add, long phne)
{
	mymoney.setActno(actnm);
	mymoney.setBal(bal);
	mymoney.setInterest();
	mymoney.setFees();
	Name = name;
	Address = add;
	phone = phne;
    
}
void Customer::setCust(int actnm, double bal, double ints, double fee, string name, string add, long phne)
{
	mymoney.setActno(actnm);
	mymoney.setBal(bal);
	mymoney.setInterest();
	mymoney.setFees();
	Name = name;
	Address = add;
	phone = phne;
}
void Customer::print()
{
	mymoney.printBal();
}


#include "checking.h"

class Customer
{
private:
	string Name;
	string Address;
	long phone;
	
public:
	checking mymoney;
	double withdrawl(double amnt);
	double deposit(double amt);
	Customer();
	Customer(int actnm, double bal, double ints, double fee, string name, string add, long phne);
	void setCust(int actnm, double bal, double ints, double fee, string name, string add, long phne);
	void print();

};


#include "checking.h"

checking::checking():Account()
{

}
checking::checking(int actnm, double bal, double ints, double fee ):Account()
{
	setBal(bal);
	setActno(actnm);
	interest = ints;
	fees = fee;
	setBal(500);


}
double checking::getInterest()
{
	return interest;
}

double checking::getFees()
{
	return fees;
}
void checking::setInterest()
{
	interest = .03;
}
void checking::setFees()
{
	fees = 10.0;
	
}
void checking::printBal()
{
	cout << " Your current balance is:  " << getBal() << endl;
}
void checking::calcIntFee()
{
	double tempi, tempf;
	tempi = getBal() * getInterest();
	tempi = tempi + getBal();
	setBal(tempi);
	tempf = getBal() + getFees();
	setBal(tempf);
}

#ifndef CHECKING_H
#define CHECKING_H
#include "Account.h"

class checking: public Account
{
private:
	double interest;
	double fees;
public:
	checking();
	checking(int actnm, double bal, double ints, double fee);
	double getInterest();
	double getFees();
	void setInterest();
	void setFees();
	void printBal();
	void calcIntFee();
	

};
#endif

#include "Account.h"

Account::Account()
{

}

Account::Account(int actnm, double bal)
{
	actNumber = actnm;
	balance = bal;
}
void Account::setBal(double bal)
{
	balance = bal;
}
double Account::getBal()
{
	return balance;
}
int Account::getActnum()
{
	return actNumber;
}
void Account::setActno(int actnm)
{
	actNumber = actnm;
}
#ifndef ACCOUNT_H
#define ACCOUNT_H
#include <iostream>>
#include <string>
using namespace std;

class Account
{
private:
	int actNumber;
	double balance;
	
public:
	virtual void printBal() = 0;
	Account();// defalut constructor
	Account(int actnm, double bal); //overloaded constructor
	void setBal(double bal);
	void setActno(int actnm);
	double getBal();
	int getActnum();
};
#endif
Posted
Updated 14-Jun-11 1:48am
v2
Comments
Sergey Alexandrovich Kryukov 13-Jun-11 22:20pm    
Why would anyone examine this code dump? Could you be more cooperative, explain you concerns? As is, it is not really a question. Also, format if correctly (apparently, you failed to replace some angular brackets with HTML entity, comment code lines with syntax errors.
--SA
babyniblet 13-Jun-11 22:41pm    
thats the thing I can not see the point where the errors are displayed. once I built it , it showed that there are errors but not where I can see and fix.
Albert Holguin 13-Jun-11 23:31pm    
compilers always give errors, they may not make sense to you but they do... you can't expect us to read through all that code and tell you every single thing that is wrong.
psych00range 14-Jun-11 0:13am    
show us what the errors you get are and we could help determine whats wrong....otherwise im not trying to look through every line and put this into my compiler and figure out what part of the files are actually supposed to go where.....you could probably host the files somewhere so someone also wouldnt have to copy paste everything
thatraja 14-Jun-11 1:03am    
Mention the error messages man so that we can help you, we can't examine your entire code like SA said.

You have included your "header files" twice each class file. And I don't believe that you need the following:

</string></iostream></string></iostream>

If what you have is in a single file, then the lines:
C#
#include "Account.h"

C#
#include "checking.h"

C#
#include "Customer.h"

as such are kind of useless.

You need to put your classes first then functions related to the class after. Since you are using inheritance, then the class that is being inherited, needs to be stated first.

AND.... You either copied it twice (HERE) or:

C#
#ifndef ACCOUNT_H
#define ACCOUNT_H
#include <iostream>
#include <string>
using namespace std;

class Account
{
private:
    int actNumber;
    double balance;

public:
    virtual void printBal() = 0;
    Account();// defalut constructor
    Account(int actnm, double bal); //overloaded constructor
    void setBal(double bal);
    void setActno(int actnm);
    double getBal();
    int getActnum();


};
#endif


C#
#ifndef ACCOUNT_H
#define ACCOUNT_H
#include <iostream>
#include <string>
using namespace std;

class Account
{
private:
    int actNumber;
    double balance;

public:
    virtual void printBal() = 0;
    Account();// defalut constructor
    Account(int actnm, double bal); //overloaded constructor
    void setBal(double bal);
    void setActno(int actnm);
    double getBal();
    int getActnum();


};
#endif


YOU HAVE DEFINED "class Account" twice... that is a killer if your debuger is below par, and leads to nebulous errors.
 
Share this answer
 
v2
Rather than ask us to do the work of your compiler, you should learn to use your own and read the error messages. As long as you cannot accomplish even that, there is no point asking about possible C/C++ errors.

That said, if you need help with your compiler or IDE, you should at the very least let us know what you are using.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900