package java1;
import java.util.Scanner;
public class hao12309 {
public static void main(String[]args){
Scanner s=new Scanner(System.in);
System.out.println("请输入周期");
int n=s.nextInt();
switch (0){
System.out.println("星期天");
case 1:
System.out.println("星期一");
case 2:
System.out.prinltn("星期二");
case 3:
System.out.println("星期三");
case 4:
System.out.println("星期四");
case 5:
System.out.println("星期五");
case 6:
System.out.println("星期六");
dreak:
System.out.println("输入有误");
}
}
}
package java1;
import java.util.Scanner;
public class hao12309{
public static void main(String[] args){
Scanner s=new Scanner(System.in);
System.out.println("请输入周期");
int n=s.nextInt();
switch (n){
case 1:
System.out.println("星期一");
break;
case 2:
System.out.println("星期二");
break;
case 3:
System.out.println("星期三");
break;
case 4:
System.out.println("星期四");
break;
case 5:
System.out.println("星期五");
break;
case 6:
System.out.println("星期六");
break;
case 7:
System.out.println("星期日");
break;
default:
System.out.println("输入有误");
}
}
}
加不加break你可以试着都运行结果看看
没有跳出循环的关键字break,还有dreak改成dfault.还有switch(n)吧。
没有跳出循环的关键字break,还有dreak改成dfault.
dreak: 改 break;