2010-09-22, 09:39 AM
A quick search on google for "c++ read from file" yields something like this http://www.cplusplus.com/forum/beginner/8388/.
Given your capability to write code above, I dont see how hard it is to merge it with the 3rd post. There're minimal changes to your code to achieve what you wanted.
Tho, rather than mashing everything together into the main function, it is advisable to split it out to multiple. Like it or not, what you written are very primitive, and most likely wont be seeing it ever in the real world environment. Another thing I tend to see is that newbie programmers tend to let hell loose in their code. Try to maintain some disciplines with your code and it'll reward you greatly when you have to maintain it later. You may not know it, but even the best of us has written shitty code, and at later time, when we looked back at it, the reactions were "wtp?? i wrote this?" or "wtp is going on in here?"
That's why I suggested you tried modifying your code to something a bit more modular and more resusable by having a new function that handles the GPA logic. There is not much additional work in doing what I suggested either. As for OOP, well, take your time with that.
Given your capability to write code above, I dont see how hard it is to merge it with the 3rd post. There're minimal changes to your code to achieve what you wanted.
Tho, rather than mashing everything together into the main function, it is advisable to split it out to multiple. Like it or not, what you written are very primitive, and most likely wont be seeing it ever in the real world environment. Another thing I tend to see is that newbie programmers tend to let hell loose in their code. Try to maintain some disciplines with your code and it'll reward you greatly when you have to maintain it later. You may not know it, but even the best of us has written shitty code, and at later time, when we looked back at it, the reactions were "wtp?? i wrote this?" or "wtp is going on in here?"
That's why I suggested you tried modifying your code to something a bit more modular and more resusable by having a new function that handles the GPA logic. There is not much additional work in doing what I suggested either. As for OOP, well, take your time with that.

