structure members are accessed with the . operator as struct.variable. They can also be accessed as pointer variables struct->varaible, but for now let's stay with the dot. The patched code contains examoles of this and comments.
If you need more help, just ask,
Jeronimo
CODE
#include <fstream>
#include <iostream>
#include <iomanip>
using namespace std;
// Function Prototypes
void DisplayTitle();
double GetBegBal();
void DisplayBal(double);
void GetData(int& , double&);
double ProcessCheck(double, double);
double ProcessDeposit(double, double);
double ProcessATM(double, double);
double ProcessSvcChg(double);
double ProcessAutopay(double, double);
//Global Constants
ifstream in_stream;
ofstream out_stream;
const double CHARGE = 10,
ATMFEE = 2;
double next;
struct chkrecord
{
int transCode;
double transAmt;
};
struct totals
{
int credits;
int debits;
int service;
};
int main()
{
//Variable Declarations
using namespace std;
//GetData(record.transCode, record.transAmt);
double balance;
in_stream.open("checkin_dat.txt");
in_stream >> next;
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(2);
//DisplayTitle();
balance = GetBegBal(); // no arguements ("checkin.dat");
chkrecord record; // must have a struct that contains this variable
// must use that struct with the variables i.e. struct.variable
record.transCode = 0; // initialize condition
GetData(record.transCode, record.transAmt);
while(record.transCode != 0)
{
switch(record.transCode)
{
case 1: balance = ProcessCheck(balance, record.transAmt); break;
case 2: balance = ProcessDeposit(balance, record.transAmt); break;
case 3: balance = ProcessATM(balance, record.transAmt); break;
case 4: balance = ProcessAutopay(balance, record.transAmt); break;
}
DisplayBal(balance);
if(balance < 0)
balance = ProcessSvcChg(balance);
record.transCode = 0; // re initialize condition
GetData(record.transCode, record.transAmt);
}
out_stream.open("checkout.txt");
system("pause");
}
/* void DisplayTitle()
{
//cout << "\n Check Register\n\n";
}*/
double GetBegBal()
{
double x;
ifstream ChkBal;
ChkBal.open("e:Checkin.dat");
ChkBal >> x;
return x;
}
void DisplayBal(double x)
{
// in_stream << "\t\tBalance = $" << setw(10) << x; cannot << to in_stream
cout << "\t\tBalance = $" << setw(10) << x;
}
void GetData(int& x, double& y)
{
cout << "\n\n Enter transaction code (0 to exit) ";
in_stream >> x;
if(next > 0)
{
// cout << "\n Enter transaction amount ";
in_stream >> next;
}
}
double ProcessCheck(double bal, double amt)
{
//cout << "\n Check = " << setw(10) << amt;
return (bal - amt);
}
double ProcessDeposit(double bal, double amt)
{
//cout << "\n Deposit = " << setw(10) << amt;
return (bal + amt);
}
double ProcessATM(double bal, double amt)
{
//cout << "\n ATM = " << setw(10) << amt;
bal = bal - amt;
DisplayBal(bal);
bal = bal - ATMFEE;
//cout << "\n ATM Fee = " << setw(10) << ATMFEE;
return (bal);
}
double ProcessSvcChg(double bal)
{
//cout << "\n Service chg =" << setw(8) << CHARGE;
bal = bal - CHARGE;
DisplayBal(bal);
return (bal);
}
double ProcessAutopay(double bal, double amt)
{
//cout << "\n Withdrawal = " << setw(10) << amt;
return (bal - amt);
}