Here are my guidelines.
You are to write a program that will sum up inventory counts and report the total. The inventory is represented by a three digit inventory number and a count of the items. Sample/Test data is given below to test your program, but the real data may be more or less items than shown.
There exists a problem with the data. Two different inventories have been mixed up in the list. The inventory number and the count still match up though. You need to separate out the two inventories and get a count for each one (ie inventory ONE and inventory TWO). The R&D department has discovered that the two inventories can be distinguished by digits in the inventory number. If the digits in the inventory number sum up to be less than or equal to 13, then those items belong to inventory ONE. The others belong to inventory TWO.
Separate and compute sums for each of the two inventories and generate a total inventory count for each one. Print out each inventory, the total number of items found in each inventory, total counts and the average for each of the two inventories. You have to write to two output files. You are given sample data below.
The input files for testing your program are in two different files. The first file has the item number. The second file has the counts.
Item File: inventoryItemNbr.txt
Count File: inventoryCount.txt
Below is sample of each file:
item 382,123,965,432,823,872,734,882,117,632,664,841,149,681,616,915,323,448,552,662,811
cnt 20,40,109,45,341,51,513,43,45,673,982,8,134,155,522,632,103,21,15,49,134
Example input for one inventory
332 20
123 40
235 109
etc
I'm not very familiar with functions or reading and writing to files. but i'm getting an error on line 9, not sure what is wrong. any tips on how functions work (passing and returning values mainly) would be greatly appreciated.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
#include <iostream>
#include <fstream>
using namespace std;
int inv1(), inv2(), cnt(), decision(), read(), open();
int main()
{
open();
infiletwo >> inv;
infileone >> counts;
decision(int inv);
read(AC);
return 0;
}
int open()
{
ifstream infileone, infiletwo;
ofstream outfileone, outfiletwo;
infile.open("inventoryCount.txt");
infiletwo.open("inventoryItemNbr.txt");
outfileone.open("outone.txt");
outfiletwo.open("outtwo.txt");
return 0;
}
int decision(int IN)
{
int AC;
while(IN != 0)
{
AC = IN % 10;
IN = IN / 10;
}
return AC;
}
int read(int AC, int IN)
{
if (AC <= 13)
inv1();
else
inv2();
}
int inv1(int IN)
{
}
int inv2()
{
}
int cnt()
{
}
|