Basically I Want to Write either A switch or if loop that iterates through multple array elements and checks if the account number is equal to the customer account number then it should check a character vlue which i want to use 3 cases for deposit ,withdrawl,and interest though interest transactions are stored as a 0.00 value so i do not want to read it in if it is not neccesary.
[# include <iostream>
# include <fstream>
# define length 4
# define Translength 21
usingnamespace std;
class savingsAccount
{
public:
int accountNumber;
float balance;
float intrestRate;
};savingsAccount account [length];
class Customer
{
public:
string fName;
string lName;
string housenum;
string streetname;
string streettype;
int SavingsAccount;
};Customer customer [length];
class Transaction
{
public:
int accNumber;
float amount;
char transType;
};Transaction transaction [length];
int main ()
{
float balance = 0;
float intrestRate = balance*0.05;
ifstream myfile ("customer.dat");
if (myfile.is_open())
{
while ( myfile.good() )
{ for (int n = 0; n <length; n++)
{
myfile >>customer[n].SavingsAccount;cout<<flush;
myfile >>customer[n].fName;
myfile >> customer[n].lName;
myfile >> customer[n].housenum; myfile >> customer[n].streetname;myfile >> customer [n].streettype;
}
myfile.close();}
{
ifstream myfile ("trans.dat");
if (myfile.is_open())
{
while ( myfile.good() )
{ for (int n = 0; n <Translength; n++)
{
myfile >> transaction[n].accNumber;
myfile >> transaction[n].amount;
myfile >> transaction[n].transType;
} myfile.close();}
{
{
cout << " Customer Report"<<endl<<endl;
for (int n = 0; n<length; n++)
{
cout <<" Customer Account Number : "<< customer[n].SavingsAccount<<endl;
cout <<"Customer Name : "<<customer[n].fName; cout << " " << customer [n].lName<<endl;
cout << "Customer Address : "<< customer[n].housenum; cout <<" " ;cout<<customer[n].streetname;cout <<" "<<customer[n].streettype<<endl;
cout << "Account Balance : " <<account[n].balance<<endl;cout<<endl;
}
{
cout<<" New Customer Balances"<<endl<<endl;
for (int n = 0; n<length; n++)
{
account[n].balance == transaction[n].amount;
cout <<" Customer Account Number : "<< customer[n].SavingsAccount<<endl;
cout <<"Customer Name : "<<customer[n].fName; cout << " " << customer [n].lName<<endl;
cout << "Customer Address : "<< customer[n].housenum; cout <<" " ;cout<<customer[n].streetname;cout <<" "<<customer[n].streettype<<endl;
cout << "Account Balance : " <<transaction[n].amount<<endl;cout<<endl;
}
{
system ("pause");
}}}}}}}}/code]
I know the code is quite sloppy and the extra } at the bottom though dev c++ complained about extra } needed
Basically I Have the code reading in from texfile correctly checking the elements though i need to write a function to compare the [code]customer[n].SavingsAccount to the transaction[n].accNumber and then I was thinking of using a switch statement to check the transaction[n].transType; then defining the 3 cases for withdrawl,Intrest and Deposit
Though i do not know how to write a switch statement that compares the account numbers and reads the array' character and amount to update account [n].balance