Ok, the problem i am having with this problem is specifically number 3.
i don't know how to take a specific piece of info from the file and convert it into a double so i can perform the arithmetic.
please help.
The Bite-a Vite-a vitamin store needs an "expert" computer programmer to help keep track of their inventory. The store maintains all their vitamin stock information on disk. The data is organized as follows:
The first column contains the vitamin name (A, B, C, etc.)
The second column contains the unit price of a single jar of that particular vitamin.
The third column has the number of jars of that vitamin in the store.
For example:
A 12.95 23
K 9.99 56
Z 6.99 25
Write a C++ program, on the next page, that will do the following:
1. Read data from a data file called inventory located on the store’s hard drive in a directory called c:\store. The store inventory fluctuates so you do not know how much data there is to process.
2. Call a function that will return the total value of the store’s inventory for that one vitamin product (unit_price * number_of_jars).
3. You will also calculate:
i) The average price of a vitamin
ii) The total inventory (total number of jars)
4. Print the output so that it is organized as follows:
This should be a good starting point for you. Once you've gone over this a little bit, you should have a better understanding of what you're looking at.
But you could also store the info in a container, to use it later.
1 2 3 4 5
vector<product> container;
while( input>>name>>price>>quantity )
container.push_back( product(name,price,quantity) );
//Now you have all the products in the vector