The Customer IDs are the numbers ranging from 1000-1004 in both files. In Java D
ID: 3744644 • Letter: T
Question
The Customer IDs are the numbers ranging from 1000-1004 in both files.
In Java
Data Structures (CIS0 M. Lowenthal (AR are Company" has hired you to wrte a program for it's Accounts Recelveble department that owe money to the company because they have purchased tems and have not yet paid for them) 1) A master file in ascending order by customer number (customer numbers are 4 digits long). The fle also 2) A transaction filie that contains records of each transaction. This file is also in ascending order by custorner The "ABC Hardware accounts There are two types of input data contains a 20 character customer name and a balance due. There should be more than one transaction record per master record Each related group of data in a Sle is called a record. A record should be stored in a structure. Each record starts with a character,for order or-P" for payment. Each record also contains the four-digt customer number, a four-digt transaction number, and up to three more values: tthe oode e o, thethe tem ordered (20 characters). the quenthy ordered (an integer plus the cost of the tem. (You must mutiply to get the total cost) If the code is "P, the record contains the amount of the payment. You are to read in records one at a time from the two files and use the transaction file records to update the master file. Process all transaction records for each master record belore going on to the next master record. If the transaction record contains an "O" in column 1, calculate the order amount and add t to the balance due. If the record contains a "P" in column 1, subtract the payment from the balance d Balance of ABC Company (That is the sum of the balances due for each customer ue. Keep a running total of the A/R Your program should... Check for errors such as duplicate master records or records in the transaction file that do not appear in the master file. After processing a master record and all it's transactions the program should prepare an invoice for each customer which ists the customer name, number, previous balance (balance before transactions were performed), all transactions, and the final balance due (balance after transactions are períormed. The output should look something like this.. CUSTOMER NAME CUSTOMER NUMBER PREVIOUS BALANCE xxx.xx TRANSACTION # TRANSACTION # TRANSACTION # ITEM ORDERED TEM ORDERED PAYMENT ITEM ORDERED S ORDER AMOUNT $ ORDER AMOUNT $ PAYMENT AMOUNT S ORDER AMOUNT BALANCE DUE Dont forget, payments reduce the balance and orders increase it. You are to create your own data using at least 7 customers with an average of 5 transactions each.Explanation / Answer
# include <iostream>
# include <fstream>
# include <iomanip>
# include <string>
using namespace std;
struct master {
double custnum;
char name[100];
double balance;
};
struct transactions {
char transtype;
int custnum;
int transnum;
char item[100];
int quantity;
double price;
double amountpaid;
};
int main ()
{
ifstream masterfile ("MASTER.txt");
ifstream transfile ("TRANSACTION.txt");
int prevbalance[7];
master main [7];
for (int i=0; !masterfile.eof(); i++) {
masterfile>>main[i].custnum>>main[i].name>>main[i].balance;
}
for (int i=0;!masterfile.eof();i++) {
cout << main[i].custnum<<" ";
cout << main[i].name<<" ";
cout << main[i].balance<<" "<<
endl<<endl;
prevbalance[i] = main[i].balance;
}
double companybalance = 0;
double orderamt=0;
transactions tran[35];
for (int i=0; !transfile.eof(); i++) {
transfile>> tran[i].transtype;
cout<<tran[i].transtype<<" ";
if (tran[i].transtype == 'O') {
transfile>>tran[i].custnum;
cout<<tran[i].custnum<<" ";
transfile>> tran[i].transnum;
cout<<tran[i].transnum<<" ";
transfile>>tran[i].item;
cout<<tran[i].item<<" ";
transfile>>tran[i].quantity;
cout<<tran[i].quantity<<" ";
transfile>>tran[i].price;
cout<<tran[i].price<<" "<<endl<<endl;
orderamt= tran[i].price*tran[i].quantity;
main[i].balance+= orderamt;
companybalance += main[i].balance;
}
else if (tran[i].transtype == 'P'){
transfile>>tran[i].custnum;
cout<<tran[i].custnum<<" ";
transfile>> tran[i].transnum;
cout<<tran[i].transnum<<" ";
transfile>>tran[i].amountpaid;
cout<<tran[i].amountpaid<<endl<<endl<<endl;
main[i].balance-tran[i].amountpaid;
companybalance += main[i].balance;
}}
for(int i=0; i<50; i++) {
cout<<"Name: "<< main[i].name <<" Customer #: "<< main[i].custnum<<endl<<endl;
cout<<"Previous Balance "<<prevbalance[i]<<endl;
for(int j=0; j<7; j++){
cout<<"Transaction #: "<<tran[j].transnum<<" "<<tran[j].item<<" $"<<orderamt<<endl; }
cout<<"Balance Due: "<<main[i].balance<<endl;
}
}
MASTER FILE:
1000 TIFFANY 7000.99
2000 MARY 6500.98
3000 JACOB 6560.99
4000 GENE 4560.98
5000 BELLA 5300.87
6000 ANNA 2340.90
7000 DEMI 4230.45
TRANSACTION FILE:
O 1000 1000 PENS 20 2
O 1000 2000 CPUS 2 200
O 1000 3000 MONITER 2 100
P 1000 4000 4000
P 1000 5000 300
O 2000 6000 CPUS 3 500
O 2000 7000 MOUSE 3 50
O 2000 8000 WIRES 5 8
P 2000 9000 600
P 2000 1100 798
O 3000 1200 MONITERS 6 60
O 3000 1300 CPUS 7 300
O 3000 1400 MOUSE 30 40
O 3000 1500 SPEAKERS 20 20
P 3000 1600 5000
O 4000 1001 SPEAKERS 2 50
O 4000 2002 CABLES 4 20
P 4000 3003 400
P 4000 4004 500
P 4000 5005 68
P 5000 6001 600
P 5000 4002 55
P 5000 2003 450
O 5000 4004 SPEAKERS 4 60
O 5000 1005 LAPTOP 3 300
O 6000 6001 TVS 5 400
O 6000 8002 SPEAKERS 5 70
P 6000 6003 2000
P 6000 8004 1000
O 6000 8005 CABLES 10 15
O 7000 5001 PENS 50 2
O 7000 7002 PAPER 400 2
P 7000 4003 150
P 7000 3004 230
P 7000 6005 450
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.