作业3-5;不懂错在哪。。看不懂
public class CharDemo {
public static void main(String[] args) {
Scanner.sc=new Scanner(System.in);
System.out.println("请输入一个字母");
String cha=next();
cha=cha.toLowercase();
//定义一个字符变量并初始化
switch (cha)
{
case "a":
System.out.println("元音字母:"+cha);break;
case "e":
System.out.println("元音字母:"+cha);break;
case "i":
System.out.println("元音字母:"+cha);break;
case "o":
System.out.println("元音字母:"+cha);break;
case "u":
System.out.println("元音字母:"+cha);break;
default:
System.out.println("不是元音字母");
}
//使用switch结构判断是否为元音字母,并输出对应的信息
}
}
CharDemo.java:3: error: cannot find symbol
Scanner.sc=new Scanner(System.in);
^
symbol: variable Scanner
location: class CharDemo
CharDemo.java:3: error: cannot find symbol
Scanner.sc=new Scanner(System.in);
^
symbol: class Scanner
location: class CharDemo
CharDemo.java:5: error: cannot find symbol
String cha=next();
^
symbol: method next()
location: class CharDemo
CharDemo.java:6: error: cannot find symbol
cha=cha.toLowercase();
^
symbol: method toLowercase()
location: variable cha of type String
4 errors
正在回答
CharDemo.java:3: error: cannot find symbol
Scanner.sc=new Scanner(System.in);
^
//package语句后加入:
import java.until.Scanner;
symbol: variable Scanner
location: class CharDemo
CharDemo.java:3: error: cannot find symbol
Scanner.sc=new Scanner(System.in);
^
//没有 · ,用空格
Scanner sc = new Scanner(System.in);
symbol: class Scanner
location: class CharDemo
CharDemo.java:5: error: cannot find symbol
String cha=next();
^
//String cha = sc.next();
symbol: method next()
location: class CharDemo
CharDemo.java:6: error: cannot find symbol
cha=cha.toLowercase();
^
//cha = cha.toLowerCase();
symbol: method toLowercase()
location: variable cha of type String
4 errors
- 参与学习 人
- 提交作业 7317 份
- 解答问题 14452 个
想要入门学编程?多年一直活跃在编程语言排行版前列的Java是一个很好的选择。本路径将从Java基础语法、面向对象、常用工具类三部分,为你开启软件开发的大门!
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星