import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.Scanner;
/*
* 【程序50】TestStu.java 题目:有五个学生,每个学生有3门课的成绩,
* 从键盘输入以上数据(包括学生号,姓名,三门课成绩),
* //计算 出平均成绩,况原有的数据和计算出的平均分数存放在磁盘
* */
public class Te1 {
public static void main(String[] args) throws Exception {
//String s ="1, wang, 94,83,72. 2, gao, 86,77,65. 3, zhong, 78,88,70";
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String s = br.readLine();
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("D:\\1.txt")));
String[] student = s.split("\\.");
int sum = 0, average = 0;
for(int i = 0; i < student.length; i++){
String s1[] = student[i].split("\\,");
for(int j = 0; j < s1.length-2; j++){
sum += Integer.parseInt(s1[j+2].trim());
average = sum / 3;
}
bw.write(student[i]);
bw.newLine();
bw.write("总分: "+sum+" 平均分:"+average);
bw.newLine();
bw.newLine();
System.out.println("总分: "+sum+" 平均分:"+average);
sum = 0;
}
br.close();
bw.flush();
bw.close();
}
}
import java.io.BufferedWriter;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.Scanner;
/*
* 【程序50】TestStu.java 题目:有五个学生,每个学生有3门课的成绩,
* 从键盘输入以上数据(包括学生号,姓名,三门课成绩),
* //计算 出平均成绩,况原有的数据和计算出的平均分数存放在磁盘
* */
public class Te1 {
public static void main(String[] args) throws Exception {
//String s ="1, wang, 94,83,72. 2, gao, 86,77,65. 3, zhong, 78,88,70";
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String s = br.readLine();
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("D:\\1.txt")));
String[] student = s.split("\\.");
int sum = 0, average = 0;
for(int i = 0; i < student.length; i++){
String s1[] = student[i].split("\\,");
for(int j = 0; j < s1.length-2; j++){
sum += Integer.parseInt(s1[j+2].trim());
average = sum / 3;
}
bw.write(student[i]);
bw.newLine();
bw.write("总分: "+sum+" 平均分:"+average);
bw.newLine();
bw.newLine();
System.out.println("总分: "+sum+" 平均分:"+average);
sum = 0;
}
br.close();
bw.flush();
bw.close();
}
}