Heres my output
As far as i can tell its reading every line from the Candy.txt file instead of just adding one.
C:\C++\Lab10>a
Candy Inventory Management Program
1. Add a piece of candy to inventory
2. Calculate totals for hard candy
3. Calculate totals for jelly beans
4. Calculate totals for chocolates
5. Calculate totals for all candy
6. Quit the program
Choose 1 - 6: 2
Candy Inventory Management Program
1. Add a piece of candy to inventory
2. Calculate totals for hard candy
3. Calculate totals for jelly beans
4. Calculate totals for chocolates
5. Calculate totals for all candy
6. Quit the program
Choose 1 - 6:
I now understand the reasons for the if statement test on mtype, but it was wrong and also in the wrong place. let me try to explain why: you are using the menu option to check against the data item.. yes? - well when selecting candy type its 1 - 3 yet on the main menu 1 is taken up by Add Candy so this would fail.
A way around that would be to subtract one from the mtype during testing... hope that made sense :)
Well other than option 5 everything is displaying correctly as per the test output of your pdf. With regards to option 5 all you needed to do is test the type[itemno] to see what value it was and print out depending on that - easy stuff - a simple switch could take care of that like so...
To be honest these kinda additions such as the one above you should be able to do now yourself after all this practice and previous discussions we've had... ;-)
ok i read over the entire program just a few minutes ago, i think i have been trying to solve an imaginary problem for the past 18 hours, i had fixed the program last night(to a working degree) i had already tried some of the corrections you suggested, as the == to just = and i found a few others before i sent it to you in the first place. It just occurred to me that the candy.txt file is supposed to display everything in it of each type. I feel so dumb right now.
Not sure if I am missing your point here but the data file layout is correct as per the pdf, i.e. it doesnt actually store the words "Hard Candy" which can be seen on page 4 of the pdf.
Haha yes sir thank you for all your help again! Ive only got a few more weeks of this class and one more program and im free!!!! But i guess i need to keep practicing afterward so ill be prepared for data structures.
Not everything on that site is free but those are, and they are pretty good. The pointers one is nice for the stage your at and video is always better than trying to dip your head into a book.
Hey, How would you make a program count the number of characters, and distinguish if those are upper or lower case then count how many of each there are in a text file? This part of one of my programs has got me stumped.