Hello all:
I'm trying to figure out input validation. The users options are either A,C,He,or H. If they cin a valid input, then I proceed with the switch that I have working.
If they put in an invalid input I'm supposed have them re-enter a value till they get it right.
Anyway how do I return to the initial prompt after they fail the first time?
Consider the only loops we have learned so for are for loops, so whiles are unavailable.
Is there someway to return to the top after the default output is displayed in the switch.
I figured if/elses won't work as that's what I've been trying:
1 2 3
|
if((selection == 'A') || (selection == 'C')||(selection == 'He')||(selection == 'H' )){
switch (selection)
|
but how do I return to the initial prompt in the else{} statement?
If you do a for loop?:
1 2 3
|
for ((selection == 'A') || (selection == 'C')||(selection == 'He')||(selection == 'H' ); ; )
switch
|
Basically can I go condition-> true -> processor -> display
condition-> false ->condition
This is the first time I'm using a for loop if I have to use one.
Any help will be great Thanks!!