|
-
October 1st, 2015, 11:18 PM
#1
basics uses of vectors for an A/R basic program
I need help in writing a program using vectors, I haven't wrote any programs in over a yrs and even then I was struggling.
I need the program to read from two files
file (1) is a master file in ascending order by customer number (4 digits long), it also contains a 20 character customer name and a balance due..
(ex. 1001 "NAME" Balance)
this is that file looks...
Code:
1001 Jack 305.78
2002 Roofing 414.67
3003 Showers 210.44
4004 Handyman 140.63
5005 repairs 490.12
6006 Mechanic 53.34
7007 Appliance 180.77
file (2) is a transaction file that contains records of each transaction.
each records start with a character "O" or "P"
if it's in "O" for the order.. containing item ordered quantity ordered plus cost of the item (I need to multiply to get the cost)
ex. (O "Customer#" "Transaction#" "description" "quantity" "price")
"P" contains the amount of payment
ex. ( P "customer#" "transaction#" "paymentAmout")
this is how that file looks...
Code:
O 1001 5493 toilets 8 56
P 1001 5494 250
P 1001 9286 54
O 1001 8884 Pipe 2 350
P 1001 9960 180
O 2002 8924 Cutter 1 2195
P 2002 1115 1034
P 2002 9182 404
O 2002 801 Shaft 1 450
P 2002 8193 555
O 3003 1734 Shower 1 621
P 3003 1112 542
P 3003 1022 324
P 3003 4401 197
P 3003 6732 32
O 4004 7731 Panels 20 9
P 4004 3215 185
P 4004 3034 52
O 4004 3218 Cement 20 12
P 4004 1888 179
O 5005 9995 Unit 1 2259
P 5005 1918 259
P 5005 1920 575
P 5005 1925 503
P 5005 1928 317
O 6006 2020 Tools 2 115
O 6006 2122 Trays 3 60
P 6006 1101 59
P 6006 1020 107
P 0006 1033 33
O 7007 2455 Dishwasher 31
O 7007 2456 Panel 2 151
P 7007 9854 81
P 7007 5515 45
P 7007 6222 231
I need the program to read in records one at a time from the two files and use the transaction file to update the master file. process all transaction records for each master record before going on to the next record. if the transactions contain an "O" in column 1, calculate the order amount and add it to the balance due. if the record contains a "P" in column 1, subtract the payment from the balance due. keep a running total of the A?R Balance of ABC Company
After processing a master record and all it's transaction the program should prepare an invoice for each customer which lists the customer name, number, previous balance.
the output should look like this
CUSTOMER NAME CUSTOMER NUMBER
PREVIOUS BALANCE $XXX.XX
TRANSACTION # ITEM ORDERED $ORDER AMOUNT
TRANSACTION # ITEM ORDERED $ORDER AMOUNT
TRANSACTION # PAYMENT $ORDER AMOUNT
TRANSACTION # ITEM ORDERED $ORDER AMOUNT
BALANCE DUE $XXX.XX
I need someone who has a patients to walk me through how to write this program.
I don't have much coding all I have is basically reading in the two files.. anything else my mind is blank.. This is what I have so far
Code:
#include<iostream>
#include<iomanip>
#include<string>
#include<cstring>
#include<fstream>
#include<vector>
struct master
{
int custNumber;
std::string custName;
double balance;
};
struct transactions
{
char transactionType;
int custNumber;
int transNumber;
std::string item;
int quantity;
double price;
double amountPaid;
};
using namespace std;
int main()
{
{
vector<master>masterData;
vector<transactions>transactionData;
ifstream masterfile("master list.txt", ios::out | ios::in | ios::binary);
ifstream transactionfile("transaction.txt", ios::out | ios::in | ios::binary);
while (masterfile)
{
master m;
masterfile>>m.custNumber>>m.custName>>m.balance;
masterData;
if(masterfile)
{
masterData.push_back(m);
}
}
while (transactionfile)
{
transactions n;
transactionfile>>n.custNumber>>n.transNumber>>n.item>>n.quantity>>n.price>>n.amountPaid;
transactionData;
if(transactionfile)
{
transactionData.push_back(n);
}
}
Thank you in advance for all your help, I know it's a lot..
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|