今天做了个关于类的使用,但是输入名字的时候报错,编译是通过了,求帮助啊
package as.bs;import *;
import java.util.Scanner;
class Student{
int ID,grade;
String name;
double Ms,Es;
void setStudent(String k,int i,int g){
name=k;
ID=i;
grade=g;
}
void setScores(double m,double n){
Ms=m;
Es=n;
}
String getAll(){
return name;
}
void getInformation(){
System.out.println("名字为"+getAll());
System.out.println("ID"+ID);
System.out.println("Ms"+Ms);
System.out.println("Es"+Es);
System.out.println("grade"+grade);
}
double sum(){
return Ms+Es;
}
}
/*import *;*/
//import java.util.Scanner;
public class Comeon{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
String name;
System.out.println("请输入你的名字");
name=sc.next();
//char k=(char)System.in.read();
//Scanner sc=new Scanner(System.in);
System.out.println("请输入你的ID");
int ID=sc.nextInt();
System.out.println("请输入你的年纪");
int g=sc.nextInt();
System.out.println("请输入你的math");
double m=sc.nextDouble();
System.out.println("请输入你english");
double n=sc.nextDouble();
Student s1=new Student();
Student s2=new Student();
s1.setStudent(name,ID,g);
s1.setScores(m,n);
System.out.println(s1.sum());
s1.getInformation();
}
}