Loading...
SCE
Home
AI Assistant
Ask Anything
Categories
Python
C#
C++
C
Visual Basic
Java
JavaScript
HTML
CSS
SQL
Git
VIEW ALL
Other
Tags
What's Hot
Featured
I'm Feeling Lucky
Latest
SCE
Loading...
Sign Up
Log In
ACCOUNTING PRO.
Posted by
JanWan
Last Updated:
November 07, 2012
Account Display
Account.h
/*
NCU
*/
#include <iostream>
#include <string>
using namespace std;
class Account//Name of the class
{
private:
//Private data members
double AccBalance;
string AccName;
public:
//Getters and Setters
void Set_AccBalance(double);
double Get_AccBalance();
void Set_AccName(string);
string Get_AccName();
//Members function
void creditUpdate(double);
void debitUpdate(double);
void interestCal();
void printInfo();
//constructor with parameter. Initialize private data variables
Account(double, string);
};
Account.cpp
/*
NCU
*/
#include <cstdlib>
#include <iostream>
#include <string>
#include "Account.h"
using namespace std;
//Setter function for account balance
void Account::Set_AccBalance(double b)
{
AccBalance = b; //initialize the variable
}
//Getter function for account balance
double Account::Get_AccBalance()
{
return AccBalance;
}
//Setter function for account name
void Account::Set_AccName(string n)
{
AccName = n;
}
//Getter function for account name
string Account::Get_AccName()
{
return AccName;
}
//Credit update function
void Account::creditUpdate(double cu)
{
double update = Get_AccBalance() + cu;
Set_AccBalance(update);
}
//Debit update function
void Account::debitUpdate(double du)
{
double wdraw; //variable declaration
wdraw = Get_AccBalance();
if(du > wdraw)
{
cout<<"The debit amount of "<<du<< " exceeded your current account balance"<<endl;
}
else
{
//calculate debit
wdraw = wdraw - du;
Set_AccBalance(wdraw);
}
}
//Interest function
void Account::interestCal()
{
//calculate the interest of the balance
double I = 0.1 * Get_AccBalance();
I = I + Get_AccBalance();
Set_AccBalance(I);
}
//Print function
void Account::printInfo()
{
cout<<"Name: "<<AccName<<endl;
//display account holder name
cout<<"Balance: "<<AccBalance<<endl;
//display account holder balance
cout<<"**********************************************************************"<<endl;
}
//Constructor with parameter
Account::Account(double b, string n)
{
Set_AccName(n);
if(b >= 0)
{
Set_AccBalance(b);
}
else
{
Set_AccBalance(0.0);
//Initialize balance to 0
cout<<"The initial balance was invalid"<<endl;
}
}
Tester.cpp
/*
NORTHERN CARIBBEAN UNIVERSITY
*/
#include <cstdlib>
#include <iostream>
#include "Account.h"
using namespace std;
int main()
{
//data value
Account holder1(100.50, "Damion Mitchell");
Account holder2(200.00, "Syrie Mitchell");
holder1.printInfo();
holder1.creditUpdate(19.50);
holder1.printInfo();
holder2.interestCal();
holder2.printInfo();
holder2.debitUpdate(221.00);
holder2.printInfo();
Account holder3(-0.65, "Jane Doe");
holder3.printInfo();
holder3.creditUpdate(1000.00);
holder3.debitUpdate(500.00);
holder3.interestCal();
holder3.printInfo();
system("PAUSE");
return 0;
}
J.W.
PRODUCTION
Related Content
Web Crawler - JaeWan Pro
JanWan
|
Feb 24, 2017