package kr.ac.jj.java201812345;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Scanner;
public class HighStudent{
String name = "No Name";
int kor;
int eng;
int mat;
int tot;
double ave;
String grade;
public HighStudent() {
}
public HighStudent(int kor, int eng, int mat) {
this.kor = kor;
this.eng = eng;
this.mat = mat;
this.Calc();
}
public HighStudent(String name, int kor, int eng, int mat) {
this(kor, eng, mat);
this.name = name;
}
public void Calc() {
this.tot = kor + eng + mat;
this.ave = this.tot / 3.0;
if(this.ave >= 90) {
this.grade = "수";
}
else if(this.ave >= 80) {
this.grade = "우";
}
else if(this.ave >= 70) {
this.grade = "미";
}
else if(this.ave >= 60) {
this.grade = "양";
}
else{
this.grade = "가";
}
}
public void Input() {
Scanner scan = new Scanner(System.in);
System.out.print("이름 : ");
this.name = scan.nextLine();
System.out.print("국어 : ");
this.kor = scan.nextInt();
System.out.print("영어 : ");
this.eng = scan.nextInt();
System.out.print("수학 : ");
this.mat = scan.nextInt();
this.Calc();
}
public void Print() {
System.out.println(
"이름 : " + this.name
+ "\t국어 : " + this.kor
+ "\t영어 : " + this.eng
+ "\t수학 : " + this.mat
+ "\t총점 : " + this.tot
//+ "\t평균 : " + this.ave
+ "\t평균 : " + String.format("%6.2f", this.ave)
+ "\t등급 : " + this.grade
);
}
public void PrintNew() {
System.out.println(
this.name
+ "\t" + this.kor
+ "\t" + this.eng
+ "\t" + String.format("%3d", this.mat)
+ "\t" + this.tot
+ "\t" + String.format("%6.2f", this.ave)
+ "\t" + this.grade
);
}
public static void PrintHead() {
System.out.println("이름\t국어\t영어\t수학\t총점\t평균\t등급");
}
public static void FilePrintHead() {
PrintWriter out = null;
try {
out = new PrintWriter(new BufferedWriter(new FileWriter("D:\\out.txt", false)));
out.println("이름\t국어\t영어\t수학\t총점\t평균\t등급");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
finally {
if(out != null) {
out.close();
}
}
}
public void FilePrint() {
PrintWriter out = null;
try {
out = new PrintWriter(new BufferedWriter(new FileWriter("D:\\out.txt", true)));
out.println(
this.name
+ "\t" + this.kor
+ "\t" + this.eng
+ "\t" + this.mat
+ "\t" + this.tot
+ "\t" + String.format("%6.2f", this.ave)
+ "\t" + this.grade
);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
finally {
if(out != null) {
out.close();
}
}
}
}