NUMBER_OF_STUDENTS is meant for int price[10] array not for string array |
Why not? Each store has a name and a price. 10 stores -> 10 names, 10 prices. You need to index the arrays by the store number.
But let's step back a second.
If you were only looking for the lowest price, you could just read each name and price and save off the lowest price and the accompanying name. But, you might need to have multiple names at the same lowest price. And additionally, you need to know all of the places that are within 10% of the lowest price. So, you need to store ALL of the names and prices that are inputted before you can determine which are going to be in list 2.
That's why your teacher recommended 2 arrays. One array will contain the name of each store, and the other array will contain the price at each store. The name needs to correspond to the price so when you find prices that fit into a list, you can determine the store name associated with it.
So, both the name and price arrays should be indexed by store number. There is no "NUMBER_OF_STUDENTS" in the problem description.
You should write your program in stages. In the first stage, merely read in the 10 store names and prices and print them back out. Make sure you can read into an array and access the array elements properly (hint - use for loops).
Next, figure out what the lowest price is and print it out.
Next, print out the names of the stores that have the lowest price.
Next ... you should have the picture by now.