Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In Java , please. Thank you! The \"ABC Hardware Company has hired you to write a

ID: 3750898 • Letter: I

Question

In Java, please. Thank you!

The "ABC Hardware Company has hired you to write a program for li's Accounts Receivable department (AR are accounts that owe money to the company because they have purchased items and have not yet paid for them) There are two types ot input data 1) A master file in ascending order by customer number (customer numbers are 4 digits long). The file also contains a 20 character customer name and a balance due. 2) A transaction file that contains records of each transaction. This file is also in ascending order by customer number There should be more than one transaction record per master record. Each related group of data in a fle is called a record. A record should be stored in a structure. Each record starts with a character, "O for order or "P for payment. Each record also contains the tour-digit customer number, a four-digit transaction number, and up to three more values: If the code is "O", the record contains the Item ordered (20 characters), the quantity ordered (an integer) plus the cost of the item. (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 before going on to the next master record. If the transaction record contains an "O" in column 1, calculate the order amount and add it to the balance due. It the record contains a "P* in column 1, subtract the payment from the balance due. Keep a running total of the AR Balance of ABC Company (That is the sum of the balances due for each customer Your program should.. Check for errors such as duplicate master records or records in the transaction file that do not appear in the master After processing a master record and all it's transactions the program should prepare an invoice for each customer which lists the customer name, number, previous balance (balance before transactions were performed), all transactions, and the final balance due (balance atter transactions are performed. The output should look something like this... CUSTOMER NAME CUSTOMER NUMBER PREVIOUS BALANCE $XXXXX SORDER AMOUNT $ORDER AMOUNT TRANSACTION # TRANSACTION # TRANSACTION # TRANSACTION # TEM ORDERED ITEM ORDERED PAYMENT ITEM ORDERED PAYMENT AMOUNT $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

SOLUTION:

# 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

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote