import java.util.Scanner;
import java.io.*;
class Student{
Scanner sc = new Scanner(System.in);
private String sno; private String name;
private int s1, s2, s3, sum;
public Student() {
String str = sc.nextLine();
String[] s = str.split(" ");
this.sno = s[0]; this.name = s[1];
this.s1 = Integer.parseInt(s[2]);
this.s2 = Integer.parseInt(s[3]);
this.s3 = Integer.parseInt(s[4]);
this.sum = s1+s2+s3;
}
public String toString() {//覆写toString()方法,返回学生信息
return "学号:"+this.sno+" "+"姓名:"+this.name+" "+"s1:"+this.s1
+" "+"s2:"+this.s2+" "+"s3:"+this.s3+" "+"总分:"+this.sum;
}
}
public class Work10_2 {
public static void main(String[] args) throws Exception{
File f = new File("D:"+File.separator+"STUDENT.txt");
OutputStream os = new FileOutputStream(f);
Student[] stu = new Student[5];//具体输入信息的功能交由Student类完成
for(int i = 0; i<5; i++) {
stu[i] = new Student();
byte[] b = new byte[stu[i].toString().length()];
b = stu[i].toString().getBytes();
os.write(b); os.write("\n".getBytes());//输入一条记录则换行
}
os.close();
}
}