Back to the Program-A-Day homepage
Problem
Keep prompting the user for input until the user inputs a, b, or c.
|
|
SideSectionTitle
Taken from http://www.flickr.com/photos/daniello/565304023/
An image or By Students section
|
Solution
The solution...
|
Code
Solution Code
import javax.swing.JOptionPane;
public class InputValidation
{
public static void main(String [ ] args)
{
String message;
message = JOptionPane.showInputDialog("Please Enter a, b or c:");
while(!message.equals("a") && !message.equals("b") && !message.equals("c"))
{
message = JOptionPane.showInputDialog("Please Enter a, b or c:");
}
}
}
|
Back to the Program-A-Day homepage