public class test2 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("请输入学生个数:");
int n = sc.nextInt();
Student [] ss = new Student[n];
for(int i=0;i
Student s = new Student();
System.out.println("请输入第"+(i+1)+"个学生信息");
System.out.println("学号:");
String id = sca.nextLine();
s.setId(id);
System.out.println("姓名:");
String name = sca.nextLine();
s.setName(name);
System.out.println("年龄:");
int age = sca.nextInt();
s.setAge(age);
System.out.println("成绩:");
double score = sca.nextDouble();
s.setScore(score);
ss[i]=s;
}
array2String(ss);
}
static void array2String(Student[] ss){
for(Student s:ss){
System.out.println(s.toString());
}
}
}
class Student{
String id;
String name;
int age;
double score;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public double getScore() {
return score;
}
public void setScore(double score) {
this.score = score;
}
@Override
public String toString() {
return "Student [id=" + id + ", name=" + name + ", age=" + age + ", score=" + score + "]";
}
}
问题定义一个表示学生的类Student。类Student数据成员包括字符型学号、字符型的姓名和整型Integer的成绩。 class student { public: 自己定义的共有
制作一个电子表格
交大我珏哥???