So I'm doing an assignment where I need to take a partID and quantity from a text file and put it into a table in the command console (dealing with tax and grand totals later) but right now I'm stuck here, what I don't understand is where I should put the if else if statements regarding the partID to determine price for that part number. When I place the if else if statements out of the while loop, it would seem to me that the equation for the price would be stored, but it doesn't show up in the loop. When I try to put the if else if statements in the while loop, it just shows up as A for all of the partIDs. How can I fix this so that the price can be determined and I can loop the statement to output the table with partID, amount ordered, and price?
First you should start by post the input file, or at least a fair sample. This way everyone will be using the same information.
I noticed: while (!in.eof()), this does not work the way you are thinking. It would work much better as: while (in >> part >> quantity).
Starting at line 30 where does "part" get it value? Since you did not initialize the variable when defined it just contains a garbage value.
After you open the file how do you know it is open and usable?
If you have studied "switch/case" it may be easier to work with than the if/else if statements.
All your magic numbers are fine, but consider making them constant variables. This way there is only 1 place to make changes and less chance of missing something especially in larger programs.
Use a look-up table. Also, your code to read the file isn't right. The stream extraction should be the while condition, not testing for eof. eof is set when a read is tried but doesn't succeed - not when a read has succeeded with no more data following. Consider (not tried):