How can I "ban" letters from being used while only letting numbers to get through? Inputting letters causes my program to crash. And if they were to input a letter or foreign character, how can I let them retry?
Thanks! I've been trying to figure that out for a while now. I do have another question. How would I be able to manipulate the number that the user enters in? The tip you gave me worked, I just don't know how to transfer it to this because it ends after I enter a number
Sorry, I found that confusing. Could you further explain what you mean? I'm fairly new at this. I think only allowing digits 0-9, ".", and "-". would work but I think I'm getting too far ahead of myself for someone who just started.
Thanks again, LB! I couldn't get it to work properly with the code that you provided me so I made some minor changes to it. Is my code proper still, or did I just get lucky?
Oops, the reason my code didn't work was because I forgot the return x; at the end: http://ideone.com/8SizAy
You don't need your line2 variable on line 19 - the point of the line variable is just to hold the most recent line of input, so re-using it is intended.
Also, why not just call the variables N1 and N2 from the start? Then you wouldn't need lines 28 and 29.