Hello i was having trouble comparing a two string and char values. What i am trying to do is if the user enters a value that is not the correct one, the JOption pane will keep asking the user to enter a correct value. Here is an example:
On this one I ask the user to enter a number between 10-24 and if the input is not within the range i asked the user, the while statement will keep asking the user to input a valid number. However, i couldn't figure out how to do this with char values. This is the best i could do but this is still not correct because i need the program to keep asking the user to input a valid letter in a while loop.
I got another program that needs to keep asking the user to input a valid answer but this time with Strings. This is also the best i could do. Now this time this program runs fine but it doesn't give me the correct outcome.
I made the program to ask the user to input "Yes" or "No" and i added a while loop so that if the user dosent input the correct answer, the while loop will keep asking the user to input a correct one. Furthermore, i want the program to ignore cases, so it dosn't matter if they input YES, yes, Yes or no, NO, No and so on. So i tried making the program and as i said it looks fine and runs but when i input the corrext input that i want, it goes to the while loop that was meant for invalid answers when in reality it is correct. Does anyone know how to fix these 2 programs?
And thank you
On this one I ask the user to enter a number between 10-24 and if the input is not within the range i asked the user, the while statement will keep asking the user to input a valid number. However, i couldn't figure out how to do this with char values. This is the best i could do but this is still not correct because i need the program to keep asking the user to input a valid letter in a while loop.
I got another program that needs to keep asking the user to input a valid answer but this time with Strings. This is also the best i could do. Now this time this program runs fine but it doesn't give me the correct outcome.
I made the program to ask the user to input "Yes" or "No" and i added a while loop so that if the user dosent input the correct answer, the while loop will keep asking the user to input a correct one. Furthermore, i want the program to ignore cases, so it dosn't matter if they input YES, yes, Yes or no, NO, No and so on. So i tried making the program and as i said it looks fine and runs but when i input the corrext input that i want, it goes to the while loop that was meant for invalid answers when in reality it is correct. Does anyone know how to fix these 2 programs?
And thank you