m0_51074304 2021-04-02 10:41 采纳率: 100%
浏览 91
已采纳

java 的是switch语句报错

这是代码

import java.io.*;
public class Score2 {
	public static void main(String args[])throws IOException
	{
		BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
			System.out.println("Please input s=");
			String str=input.readLine();
			int s=Integer.parseInt(str);
			int flag=s/10;
			System.out.println(flag);
			swtich(flag)
			{
				case 0:
				case 1:
				case 2:
				case 3:
				case 4:
				case 5:
				case 6:System.out.println("不及格");break;
				case 7:System.out.println("及格");break;
				case 8:System.out.println("中");break;
				case 9:System.out.println("良");break;
				case 10:System.out.println("优");break;
				default:System.out.println("Error!");break;
			}
	}
}

这是显示的错误

Exception in thread "main" java.lang.Error: Unresolved compilation problems: 
    Syntax error on tokens, Label expected instead
    Syntax error on token "case", assert expected
    Syntax error on token "case", assert expected
    Syntax error on token "case", assert expected
    Syntax error on token "case", assert expected
    Syntax error on token "default", invalid Label
    Syntax error on token "}", delete this token

    at Score2.main(Score2.java:12)
 

  • 写回答

5条回答 默认 最新

  • 劳资nice 2021-04-02 10:54
    关注

    仔细看看 switch拼错了

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 用hfss做微带贴片阵列天线的时候分析设置有问题
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据
  • ¥20 软件测试决策法疑问求解答