C
chuck
I need some help with validating user input. I am writing a C computer
program for an intro to C course. Here is the situation. I am
creating an application that will do currency conversions. The user
will be presented with a list of 5 selections they can make. They will
then be prompted for which selection they want to enter (which can only
be 1-5, no characters or anything like it). Once they select the
number, 1 for Euro, 2 for Deutsche Mark etc, it will prompt you for how
many US dollars you want to convert to your selected currency. After
entering a dollar number > 0, it will do the conversion and display it
for you. My problem has been is validating user input and how to go
about it. During the step for selecting what currency you want to
convert to and when entering the amount of use dollars, they have to be
certain data types. For the selection they can only be ints 1-5. If
it is anything else they will go thru a loop and be prompted again to
give a selection number (1-5). I have been unsuccessful in doing this
so I decided to start over. The link below has what I have so far and
now when I put a character say 'f' when it asks me for a selection
number, it asks me again for a selection # (meaning that i inputted a
wrong data type). The only thing is though that when I enter a 1 to
select Euro the app does absolutely nothing. I have a feeling I messed
up my loop. Can anyone help? The pastebin link is below.
http://pastebin.com/763164
If any further information is needed please let me know. Thank in
advance!
program for an intro to C course. Here is the situation. I am
creating an application that will do currency conversions. The user
will be presented with a list of 5 selections they can make. They will
then be prompted for which selection they want to enter (which can only
be 1-5, no characters or anything like it). Once they select the
number, 1 for Euro, 2 for Deutsche Mark etc, it will prompt you for how
many US dollars you want to convert to your selected currency. After
entering a dollar number > 0, it will do the conversion and display it
for you. My problem has been is validating user input and how to go
about it. During the step for selecting what currency you want to
convert to and when entering the amount of use dollars, they have to be
certain data types. For the selection they can only be ints 1-5. If
it is anything else they will go thru a loop and be prompted again to
give a selection number (1-5). I have been unsuccessful in doing this
so I decided to start over. The link below has what I have so far and
now when I put a character say 'f' when it asks me for a selection
number, it asks me again for a selection # (meaning that i inputted a
wrong data type). The only thing is though that when I enter a 1 to
select Euro the app does absolutely nothing. I have a feeling I messed
up my loop. Can anyone help? The pastebin link is below.
http://pastebin.com/763164
If any further information is needed please let me know. Thank in
advance!