Quote (irimi @ Jul 3 2012 04:45pm)
the code you wrote that followed my pseudocode ended up resembling nothing like it. for one thing, i didn't write two while loops. for another, it wasn't written for gathering multiple values - it was written to do input validation on a single value (you were complaining about not being able to properly validate and re-prompt for interest rate values), though it could easily be adapted to collect multiple values.
you seem to have a pretty shallow understanding of how control flow works. i'd suggest that you spend some time looking at code and running it through your head line by line, rather than doing things by simple trial and error. knowing how your code runs is one of the fundamental requirements to becoming a competent programmer, and it's kind of the point of this exercise anyhow.
finally, i have fairly little interest in convincing you that i'm right. i have no stake in this either way.
edit: instead of a continue in your if statement, all you needed was to put the rest of the code in an else clause
Well I didn't know at first that my initial code wasn't working - I had to test it again and found out (hence the edit)
I spent a good time last night and I eventually DID figure out that this supposed 'flow' was not correct. Though I am not quite sure about this flow you speak of - the class I am in is an intro one, and no speak of this flow has been done. Though I will probably figure it out sooner or later.
If my understanding is 'shallow', it is because I have been in an intro class only and for less than 2 months. No other previous experience really. I thought I conveyed this before...
I am not sure if you came here to help or to just call me names - because if I wanted someone to argue ad hominems w/, I would go to general chat or something.
Anyways, I will see if that works...
Code
while (cin >> x) {
if (x<0)
cout << "Negative number detected: Ignored." << endl;
else {
total *= 1+ rate;
total += x;
total += x*rate;
}
}
works
This post was edited by Eep on Jul 3 2012 04:03pm