import java.util.*;
class Gender {
private int id;
public Gender(int id) {
this.id = id;
}
@Override
public String toString
() { switch(id) {
case 0: return "女子";
case 1: return "男子";
}
}
}
class Student {
private int id;
private Gender gender;
private int nlang;
private int math;
private int eng;
public Student
(int id,
String name, Gender gender,
int...
subs) { this.id = id;
this.name = name;
this.gender = gender;
this.nlang = subs[0];
this.math = subs[1];
this.eng = subs[2];
}
public int getSum() { return nlang + math + eng; }
public String getAve
() { return String.
format("%.1f", getSum
() / 3.
); } int sum = getSum();
if(sum == 300) { return "S"; }
else if(270 <= sum && sum <= 299) { return "A"; }
else if(240 <= sum && sum <= 269) { return "B"; }
else if(180 <= sum && sum <= 239) { return "C"; }
else { return "不合格"; }
}
@Override
public String toString
() { return id + "\t" + name + "\t" + gender + "\t" + nlang + "\t" + math + "\t" + eng + "\t" + getAve() + "\t" + getSum() + "\t" + getAward();
}
}
public class Main {
private Scanner sc;
private String[] subjects
= { "国語",
"数学",
"英語" }; private List<Student> students;
public Main() {
this.
sc = new Scanner
(System.
in); this.students = new ArrayList<Student>();
}
private void doIt() {
System.
out.
printf("人数を自然数で入力してください: "); int n = sc.nextInt();
for(int i=0; i<n; i++) {
Gender gender = null;
int[] subs = { 0, 0, 0 };
System.
out.
printf("%d人目の名前を入力してください: ",
(i
+1)); name = sc.next();
System.
out.
printf("%d人目の性別を入力してください(0 女子, 1 男子): ",
(i
+1)); gender = new Gender(sc.nextInt());
for(int j=0; j<subjects.length; j++) {
System.
out.
printf("%d人目の%sの成績を入力してください: ",
(i
+1), subjects
[j
]); subs[j] = sc.nextInt();
}
Student student = new Student(i+1, name, gender, subs);
students.add(student);
}
System.
out.
printf("番号\t名前\t性別\t国語\t数学\t英語\t平均\t総合点\t判定\n"); System.
out.
printf("--------------------------------------------------------------------------\n"); for(Student s : students) {
}
System.
out.
printf("--------------------------------------------------------------------------\n"); }
public static void main
(String[] args
) { new Main
().
doIt(); } }
aW1wb3J0IGphdmEudXRpbC4qOwoKY2xhc3MgR2VuZGVyI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l5Yqb44GX44Gm44GP44Gg44GV44GEOiAiKTsKICAgICAgICBpbnQgbiA9IHNjLm5leHRJbnQoKTsKICAgICAgICBTeXN0ZW0ub3V0LnByaW50ZigiXG4iKTsKICAgICAgICBmb3IoaW50IGk9MDsgaTxuOyBpKyspIHsKICAgICAgICAgICAgR2VuZGVyIGdlbmRlciA9IG51bGw7CiAgICAgICAgICAgIFN0cmluZyBuYW1lID0gbnVsbDsKICAgICAgICAgICAgaW50W10gc3VicyA9IHsgMCwgMCwgMCB9OwogICAgICAgICAgICBTeXN0ZW0ub3V0LnByaW50ZigiJWTkurrnm67jga7lkI3liY3jgpLlhaXlipvjgZfjgabjgY/jgaDjgZXjgYQ6ICIsIChpKzEpKTsKICAgICAgICAgICAgbmFtZSA9IHNjLm5leHQoKTsKICAgICAgICAgICAgU3lzdGVtLm91dC5wcmludGYoIiVk5Lq655uu44Gu5oCn5Yil44KS5YWl5Yqb44GX44Gm44GP44Gg44GV44GEKDAg5aWz5a2QLCAxIOeUt+WtkCk6ICIsIChpKzEpKTsKICAgICAgICAgICAgZ2VuZGVyID0gbmV3IEdlbmRlcihzYy5uZXh0SW50KCkpOwogICAgICAgICAgICBmb3IoaW50IGo9MDsgajxzdWJqZWN0cy5sZW5ndGg7IGorKykgewogICAgICAgICAgICAgICAgU3lzdGVtLm91dC5wcmludGYoIiVk5Lq655uu44GuJXPjga7miJDnuL7jgpLlhaXlipvjgZfjgabjgY/jgaDjgZXjgYQ6ICIsIChpKzEpLCBzdWJqZWN0c1tqXSk7CiAgICAgICAgICAgICAgICBzdWJzW2pdID0gc2MubmV4dEludCgpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIFN0dWRlbnQgc3R1ZGVudCA9IG5ldyBTdHVkZW50KGkrMSwgbmFtZSwgZ2VuZGVyLCBzdWJzKTsKICAgICAgICAgICAgc3R1ZGVudHMuYWRkKHN0dWRlbnQpOwogICAgICAgICAgICBTeXN0ZW0ub3V0LnByaW50ZigiXG4iKTsKICAgICA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