Monthly Accounting Statements using structure


You have been hired to maintain and produce an accounting report for charges and payments for a local retail store. You are to set up a record for each costumer with there current balance. You are to read in the charges and/or payments that each customer makes against his account. The customer and charge/payment data will be found in files.

The costumes data file format is as follows:
a. An account number: 6 digit positive number
b. Name and address of the customer: up to 50 chars.
c. Current balance: a positive number for debits (if the customer owes money to the store), a negative number for credits (the stores owes money to customer.

For each purchase made by a customer a "charge card" has the following fields:
a. the account number
b. the word CHARGE
c the amount of purchase, a positive number.

For each payment made by a customer a "payment card" has the following fields:
a. the account number
b. the word PAYMENT
c. the amount paid, a positive number

Using the charge data and payment data and the customer file, write a program to
a. print out a monthly statement for each customer
b. print the updated customer file.

Note that for each customer there could be no charge data or payment data or there could be one or more charge data or payment data for a given customer.
The monthly statement for each customer should show the
a. account number
b. the name and address
c. all payments
d. all charges
e. previous balance
f. new balance
Include in the charges a 2.3% interest and handling fee based on the balance in the customer file, if the balance is positive. Else, a flat $7.00 charge otherwise. You may assume there are no more the 30 customers and for each customer there will be no more than 15 charges and no more than 10 payments for a given month.

Input files: Customer.txt

631502 Legg T. 2839 Lionel Ave. +16.30
180003 Hofstra M. 225 Smith Str -6.00
000963 Malioneyh P. J. 4344 Nero Rd +366.92
517724 Morier G. E. 19 Cumberland Ave +60.40
432649 Hauser M. 2940 Toronto Rd 0.00
817387 Currie W. D. 281 Harvard Str +55.00
913478 Hoos R. Dadie 821 County Road -100.00
713422 Smelly Tau 7281 Tobe Cir 0.00

month 1:..........
180003 PAYMENT 4.00
000963 CHARGE 23.88
817387 PAYMENT 55.00
000963 CHARGE 10.00
000963 PAYMENT 60.00
517724 CHARGE 3.43
631502 CHARGE 118.60
000963 CHARGE 15.75
432649 CHARGE 50.00
913478 CHARGE 45.00
713422 CHARGE 15.00
631502 CHARGE 100.00
913478 CHARGE 75.00
000963 PAYMENT 125.00
713422 CHARGE 63.80
432649 PAYMENT 25.00
913478 PAYMENT 200.00
631502 PAYMENT 50.00
713422 CHARGE 47.25
913478 CHARGE 5.00
432649 PAYMENT 25.00
631502 CHARGE 75.00
713422 PAYMENT 150.00

month 2.............
180003 PAYMENT 34.00
631502 PAYMENT 150.00
432649 PAYMENT 25.00
631502 CHARGE 25.00
913478 CHARGE 35.00
713422 CHARGE 47.25
432649 PAYMENT 48.00
913478 PAYMENT 250.00
517724 CHARGE 23.43
631502 CHARGE 18.60
000963 PAYMENT 125.00
713422 CHARGE 43.80
713422 CHARGE 15.00
631502 CHARGE 50.00
000963 PAYMENT 60.00
913478 CHARGE 5.00
000963 CHARGE 65.75
432649 CHARGE 50.00
913478 CHARGE 105.00
000963 CHARGE 23.88
817387 PAYMENT 55.00
000963 CHARGE 10.00
713422 PAYMENT 150.00

That's nice too.
lol wut
THE PROBLEM I HAVE DONE SO FAR>>>>>>>>>>>>>>>>>>>>>

#include<iostream>
#include<fstream>
#include<string>
using namespace std;
struct customer{
int account;
char name[50];
float balance;

};
struct month{
int id;
string type;
float amount;float chargeamt,paymentamt;
};
void read(ifstream &infile1,ifstream &infile2,ifstream &infile3,customer cust[],month m1[],month m2[],int&n,int&count);
void calculate(ifstream &infile1,ifstream &infile2,ifstream &infile3,customer tempcust[],month temp[],int&n,int&count);
int main()
{
ifstream infile1;
ifstream infile2;
ifstream infile3;
infile1.open("customer.txt");
infile2.open("month1.txt");
infile3.open("month2.txt");
customer cust[30],tempcust[1000];
month m1[23],temp[46];
month m2[23];
int n=0;
int count=0;
read(infile1,infile2,infile3,cust,m1,m2,n,count);
int a,b,z=0;int q=0;
for(int i=0;i<n;i++)
{
tempcust[i]=cust[i];
q++;
}
for(int j=q,i=0;j<(n*2);j++,i++)
{
tempcust[j]=cust[i];
}
for(a=0;a<count;a++)
{
temp[a]=m1[a];
z++;

}
for(b=z,a=0;b<46;b++,a++)
{
temp[b]=m2[a];
}
//***********************************************************
calculate(infile1,infile2,infile3,tempcust,temp,n,count);
infile1.close();
infile2.close();
infile3.close();
system("PAUSE");
return 0;
}
void read(ifstream &infile1,ifstream &infile2,ifstream &infile3,customer cust[],month m1[],month m2[],int&n,int&count)
{
while(!infile1.eof())
{
infile1>>cust[n].account;
infile1.get(cust[n].name,50);
infile1>>cust[n].balance;
n++;
}
n--;
while(!infile2.eof()&&!infile3.eof())
{
infile2>>m1[count].id>>m1[count].type>>m1[count].amount;
infile3>>m2[count].id>>m2[count].type>>m2[count].amount;
count++;
}
count--;
}
void calculate(ifstream &infile1,ifstream &infile2,ifstream &infile3,customer tempcust[],month temp[],int&n,int&count)
{
//comparing the values now.................
for(int i=0;i<(count*2);i++)//STUCK FROM HERE?????????????????????????????????????
{
for(int j=1;j<=(count*2);j++)
{
if(temp[i].id==temp[j].id)
{
if((temp[i].type=="PAYMENT")&&(temp[j].type="PAYMENT"))
{
temp[j].paymentamt=temp[j].paymentamt+temp[i].amount;
}else{temp[j].chargeamt=temp[j].chargeamt+temp[i].amount;}
}
}
for(int i=0;i<(2*count);i++)
{
cout<<temp[i].paymentamt<<endl;
}
}
}

DOES ANY BODY HAVE AN IDEA FOR COMPARING PAYMENT AND CHARGE AND ADD EACH PAYMENT AND CHARGE FOR EACH CUSTOMER>>>>>>>>>>>>>>

for(int i=0;i<(count*2);i++)//STUCK FROM HERE?????????????????????????????????????
{
for(int j=1;j<=(count*2);j++)
{
if(temp[i].id==temp[j].id)
{
if((temp[i].type=="PAYMENT")&&(temp[j].type="PAYMENT"))
{
temp[j].paymentamt=temp[j].paymentamt+temp[i].amount;
}else{temp[j].chargeamt=temp[j].chargeamt+temp[i].amount;}
}
}
for(int i=0;i<(2*count);i++)
{
cout<<temp[i].paymentamt<<endl;
}
}
}
Topic archived. No new replies allowed.