import java.util.*;
import java.io.*;
class Student {
private String name;
private int age;
private int javaScore;
private int cScore;
public Student(String name,int age) {
this.name = name;
this.age = age;
}
public void setJavaScore(int java) {
if(java < 101 && java >= 0) {
this.javaScore = java;
}else{
System.out.println("Wrong score !");
}
}
public int getJavaScore() {
return this.javaScore;
}
public void setCScore(int C) {
if(C < 101 && C >= 0) {
this.cScore = C;
}else{
System.out.println("Wrong score !");
}
}
public int getCScore() {
return this.cScore;
}
public String toString() {
return this.name+" "+this.age+" "+this.javaScore+" "+this.cScore+"\n";
}
}
class TestChengji {
public static void main(String [] args) throws Exception{
Student[] StudentInfo = new Student[3];
Scanner in = new Scanner(System.in);
System.out.println("请输入学生姓名 年龄 c语言成绩与java的成绩,中间用空格隔开:");
System.out.println("例如: 小明 18 82 80");
for(int i=0;i<3;i++) {
System.out.println("请输入数据:");
StudentInfo[i] = new Student(in.next(),in.nextInt());
StudentInfo[i].setCScore(in.nextInt());
StudentInfo[i].setJavaScore(in.nextInt());
}
in.close();
BufferedWriter writer = new BufferedWriter(new FileWriter("chengji.txt"));
for(int i=0;i<3;i++) {
writer.write(StudentInfo[i].toString());
writer.flush();
}
writer.close();
}
}
//试试