The error message says it all. The
showInputDialog method returns a string so you cannot assign it to an integer datatype. What you would need to do is convert it to an integer first.
import javax.swing.JOptionPane;
public class ito
{
public static void main(String[] args)
{
String input = JOptionPane.showInputDialog("Enter number: ");
int number = Integer.parseInt(input);
switch(number)
{
case 0:
System.out.println("you typed zero");
break;
case 1:
System.out.println("you typed one");
break;
default:
System.out.println("you didn't type zero or one");
break;
}
System.exit(0);
}}
Of course it would probably be a good idea to add in some code to validate the input to ensure it actually is a number that they entered and also the required number of digits.