0
Char Validation
I need help. I want to make another method that says: if the character entered in the list, SA[n], is not A, B, C, D, or X, the program should stop[System.exit(0)]. i want the SA[n] list to only be able to accept A or B or C or D or X. https://code.sololearn.com/cDsmm2bB5Yy3/?ref=app
1 Respuesta
+ 3
You can use an if statement to check if the char is in the character range 'A' through 'D' or is equal to 'X'.
if(ch >= 'A' && ch <= 'D' || ch == 'X') {
... true case statement(s)
} else {
... false case statements
}