Code

Topics: Carriage return, Interest, C++ Pages: 4 (684 words) Published: August 14, 2013
Name: Zachary Quek Suan ChiehI.D.: 112051-06965-010Course: BCS

account.h
using namespace std;
class Account{protected: double balance;
public: Account(double x){
balance = x;}
virtual double getBalance();
virtual double debit(double x);
virtual double credit(double x);};

account.cpp
#include<iostream>
#include"account.h"
using namespace std;
double Account:: debit(double x){
if(x>balance){
cout << "Debit amount exceeded account balance." << endl;}
else{balance = balance - x;}
return balance;}
double Account:: credit(double x){
balance = balance + x;
return balance;}
double Account::getBalance(){
return balance;};

savingaccount.h
using namespace std;
class SavingAccount : public Account {
private:
double interest;
public:
SavingAccount(double x,double y);
double calculateInterenst(double x);};

Savingaccount.cpp
#include<iostream>
#include"account.h"
#include"savingaccount.h"
using namespace std;
SavingAccount::SavingAccount(double x, double y): Account(x){ balance =x ;
interest =y;}
double SavingAccount::calculateInterenst(double x){
x = balance * interest;
return x;}

Checkingaccount.h
using namespace std;
class CheckingAccount : public Account{
private: double fee;
public: CheckingAccount(double x, double y);
virtual double debit(double x);
virtual double credit(double x);};
Checkingaccount.cpp
#include<iostream>
#include"account.h"
#include"checkingaccount.h"
using namespace std;
CheckingAccount :: CheckingAccount(double x, double y): Account(x){ balance =x ;
fee =y;}
double CheckingAccount :: debit(double x){
if(x>balance){cout << "Debit amount exceeded account balance." << endl;}
else{
balance = balance - x;
cout << "$" << fee << " transaction fee charged." << endl;
balance = balance - fee;
return balance;}}
double CheckingAccount :: credit(double x){
balance = balance + x;...
Continue Reading

Please join StudyMode to read the full document

You May Also Find These Documents Helpful

  • Essay about Comparison of Aaca and Apa Ethic Codes
  • The Code of the Street Essay
  • Linear Block Codes Essay
  • Comparing the Aca and Aacc Code of Ethics Research Paper
  • Code of Ethics Comparison Essay
  • Essay on Assigning EM Codes
  • Assigning Evaluation and Management Codes
  • Aicpa vs Ima Length of code Essay

Become a StudyMode Member

Sign Up - It's Free