编写java程序,接受用户输入的1~12之间 的整数,若不符合条件则重输入
packageChapeter2;importjava.util.Scanner;publicclassTest6{publicstaticvoidmain(String...
package Chapeter2;
import java.util.Scanner;
public class Test6
{
public static void main(String args[])
{
int n;
System.out.println("请输入1~12之间的整数");
Scanner read=new Scanner(System.in);
search:
n=read.nextInt();
if(n<1||n>12)
continue search;
switch(n)
{
case 1:
System.out.println("This month is January.");
break;
case 2:
break;
case 3:
break;
case 4:
break;
case 5:
break;
case 6:
break;
case 7:
break;
}
}
}
continue 语句使用时报错请问为什么? 展开
import java.util.Scanner;
public class Test6
{
public static void main(String args[])
{
int n;
System.out.println("请输入1~12之间的整数");
Scanner read=new Scanner(System.in);
search:
n=read.nextInt();
if(n<1||n>12)
continue search;
switch(n)
{
case 1:
System.out.println("This month is January.");
break;
case 2:
break;
case 3:
break;
case 4:
break;
case 5:
break;
case 6:
break;
case 7:
break;
}
}
}
continue 语句使用时报错请问为什么? 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询