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:
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."
using namespace std;
void sortInventory(string inventoryItems, int numberInStock,float sellingPrices)
int startScan, minIndex;
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;