Need help to code a program which:
- validate user input, accept values that a user has entered (ex, a, b, c, d, e)
- any other values other than these are to be treated invalid with a message and block it from processing.
- Prompt the user to enter the values again.
- The code should do this until a valid value has been entered.
- once a valid value has been entered it is to continue processing.

Need help to code a program which:
- validate user input, accept values that a user has entered (ex, a, b, c, d, e)
- any other values other than these are to be treated invalid with a message and block it from processing.
- Prompt the user to enter the values again.
- The code should do this until a valid value has been entered.
- once a valid value has been entered it is to continue processing.

On homework problems like that we do request some coding effort on your part.

for this type of programme a while loop would be best. have a method to display whatever and accept input and return into the while where you can validate it. If the input is valid process whatever and break the loop else display error message have the user to press enter and go back to the display method.

Edited 6 Years Ago by baki100: n/a

This article has been dead for over six months. Start a new discussion instead.