How to dispose of unused characters
Hello I am currently in a 1st year Comp sci class and am having trouble with one aspect of a program I am trying to write. Basically the program calculates tax payable based upon whether or not the user has a dependent and their income. a sample run could look like this.............................
Do you have any dependants (y/n) -> maybe
You must answer with a 'y' or an 'n'.
Do you have any dependants (y/n) -> yes 53000
What is your income -> -3000.00
Income entered must be non-negative.
What is your income -> -53000.00
Income entered must be non-negative.
What is your income -> 53000.00
Your tax payable is $5600.00
The problem is if the first data item on the line is correct then it must be used. All other data on the line must be ignored. so if when asked Do you have any dependents the user could enter: yes 53000 . and the 'y' would be read in and everything else would be discarded so its not stored and used in the tax calculation which would be problematic. So could anyone let me know how I could do this?