File into three arrays help

Hi every one ,Please I need some help with this. A guide and a short code to built on .

I wants to computerize inventory records. So am requested to
write a program that maintain a file (inv.dat )that will have product name,
number in stock, and selling price on separate lines. example:


Paper Towels
350 2.65
Coffee
300 6.00
Canned Beans
2300 0.36
The program will first read the file so that the first column (product names) goes into a string array
, the second column (number in stock) goes into an integer array , and the
third column (selling price) goes into a float array.
The program then ask the user if there are new products to be added to the file. The new
products will be read from the keyboard and written to the file.
Next, the program will sort the three arrays together.
Finally, a four column display of the contents of the arrays will be displayed with the final
column containing calculated values of number_in_stock*selling_price.
I know a little about c++ and i take online class , so I read allot of topics from this forum. I now know that I have to make some functions and it's ok. but how to read from a fie into three arrays " please give me a code to guide."
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
54
55

#include<iostream>
#include<fstream>
using namespace std;
int main()


{
	fstream myfile;
	myfile.open("inv.dat");
	
	
	
	
	
	return 0;
}


void sortInventory(string inventoryItems[], int numberInStock[],float sellingPrices[])
 {
int startScan, minIndex;
string tempItem;
int tempInStock;
float tempPrice;
for (startScan = 0; startScan < (size - 1); startScan++)
{
minIndex = startScan;

for(int index = startScan + 1; index < size; index++)
{
if (array[index] < minValue)
{

minIndex = index;
}
}



tempItem = inventoryItems[minIndex];
tempInStock = numberInStock[minIndex];
tempPrice = sellingPrices[minIndex];
inventoryItems[minIndex] = inventoryItems[startScan];
numberInStock[minIndex] = numberInStock[startScan];
sellingPrices[minIndex] = sellingPrices[startScan];
inventoryItems[startScan] = tempItem;
numberInStock[startScan] = tempInStock
sellingPrices[startScan] = tempPrice;
}
 }





Thank you
Last edited on
Topic archived. No new replies allowed.