Hello all.
I am currently working on creating a program of a Checking Account and Savings Account. I am using my input file for deposits and withdraws. However, for my deposit and withdraw functions, I am unsure what to put in it. For those functions, am I suppose to read into the file and grab the information from the input file? This is my first time using a file with Classes. Any help is appreciated. Thanks
Input file looks like:
Deposit Savings 15.00
Withdraw Checking 7.00
etc.
I read into the file from main.cpp
Account.cpp
class SavingsAccount
{
public:
SavingsAccount();
SavingsAccount(double balance);
void setBalance(double amount);
void withdraw(double amount);
void deposit(double amount);
double getBalance();
SavingsAccount::~SavingsAccount();
private:
double balance;
const double WITHDRAWAL_FEE = 0.0;
}
class CheckingAccount
{
public:
CheckingAccount();
CheckingAccount(double balance);
void setBalance(double amount);
void withdraw(double amount);
void deposit(double amount);
double getBalance();
CheckingAccount::~CheckingAccount();
private:
double balance;
double WITHDRAW_FEE = 0.5;
};
void SavingsAccount::SavingsAccount()
{
balance = 100.00;
}
void SavingsAccount::setBalance(double amount)
{
balance = amount;
}
void SavingsAccount::withdraw(double amount)
{
}
void SavingsAccount::deposit(double amount)
{
}
double SavingsAccount::getBalance()
{
return balance;
}
SavingsAccount::~SavingsAccount()
{
}
void CheckingAccount::CheckingAccount()
{
balance = 100.00;
}
void CheckingAccount::setBalance(double amount)
{
balance = amount;
}
void CheckingAccount::withdraw(double amount)
{
}
void CheckingAccount::deposit(double amount)
{
}
double CheckingAccount::getBalance()
{
}
Account.h
#include <fstream>
using namespace std;
#include "---------.h"
int main()
{
Savings SavingsAcct;
SavingsAcct.getbalance();
savingsAcct.setbalance(amount);
savingsAcct.withdraw(amount);
savingsAcct.deposit(amount);
Checking CheckingAcct;
checkingAcct.getbalance();
checkingAcct.setbalance(amount);
checkingAcct.withdraw(amount);
checkingAcct.deposit(amount);
cout<<endl;
system ("PAUSE");
return 0;
}
main.cpp
#include <fstream>
using namespace std;
#include "COSC214Lab3.h"
int main()
{
SavingsAccount savingsAcct();
CheckingAccount checkingAcct();
ifstream inData("input.txt");
ofstream outData("output.txt");
while(inData >> transactionType >> accountType >> amount)
{
if(accountType == 'savings')
{
if(transactionType == 'deposit')
{
savingsAcct.deposit(amount);
}
else if(transactionType == 'withdraw')
{
savingsAcct.withdraw(amount);
}
}
else if(accountType == 'checking')
{
if(transactionType == 'deposit')
{
checkingAcct.deposit(amount);
}
else if(transactionType == 'withdraw')
{
checkingAcct.withdraw(amount);
}
}
}
outData << "Savings Total: " << savingsAcct.getBalance() << endl;
outData << "Checking Total: " << checkingAcct.getBalance() << endl;
system ("PAUSE");
return 0;
}