import java.util.Scanner;
class StudentRecord {
private String name;
private int quiz1;
private int quiz2;
private int quiz3;
private int midterm;
private int finale;
public void setname(String x) {
name = x;
}
public void setquiz1(int x) {
quiz1 = x;
}
public void setquiz2(int x) {
quiz2 = x;
}
public void setquiz3(int x) {
quiz3 = x;
}
public void setmidterm(int x) {
midterm = x;
}
public void setfinale(int x) {
finale = x;
}
public String getname() {
return name;
}
public int getquiz1() {
return quiz1;
}
public int getquiz2() {
return quiz2;
}
public int getquiz3() {
return quiz3;
}
public int getmidterm() {
return midterm;
}
public int getfinale() {
return finale;
}
}
class StudentGrader extends StudentRecord{
private double total_percent;
private double grade;
double k;
public double qiqi(int x, int y, int z){
if((this.getquiz1() > this.getquiz3() && this.getquiz2() > this.getquiz3()) && (this.getquiz1()==this.getquiz2() || this.getquiz1()>=this.getquiz2() || this.getquiz1()<=this.getquiz2()))
k= ((this.getquiz1()+this.getquiz2())/20) *100;
else if((this.getquiz2() > this.getquiz1() && this.getquiz3() > this.getquiz1()) && (this.getquiz2()==this.getquiz3() || this.getquiz2()>=this.getquiz3() || this.getquiz2()<=this.getquiz3()))
k= ((this.getquiz2()+this.getquiz3())/20) *100;
else if((this.getquiz1() > this.getquiz2() && this.getquiz3() > this.getquiz2()) && (this.getquiz1()==this.getquiz3() || this.getquiz1()>=this.getquiz3() || this.getquiz1()<=this.getquiz3()))
k= ((this.getquiz1()+this.getquiz3())/20) *100;
else if(this.getquiz1()==this.getquiz2()||this.getquiz1()==this.getquiz3()||this.getquiz2()==this.getquiz3())
k= ((this.getquiz1()+this.getquiz2())/20) *100;
return k;
}
public void settotal_percent(double x, double y, double z) {
x = this.getmidterm() * 0.25;
y = this.getfinale() * 0.5;
z = this.qiqi(getquiz1(), getquiz2(), getquiz3())*0.25;
total_percent = x + y + z;
}
public double gettotal_percent() {
return total_percent;
}
}
public class Student {
public static void main(String[] args) {
Scanner A = new Scanner(System.in);
StudentRecord a = new StudentRecord();
StudentGrader b = new StudentGrader();
System.out.print("student_name\\tQuiz1\\tQuiz2\\tQuiz3\\tMidterm\\tFinal");
String na = A.next();
int qz1 = A.nextInt();
int qz2 = A.nextInt();
int qz3 = A.nextInt();
int mi = A.nextInt();
int fi = A.nextInt();
a.setquiz1(100);
a.setname(na);
a.setquiz1(qz1);
a.setquiz2(qz2);
a.setquiz3(qz3);
a.setmidterm(mi);
a.setfinale(fi);
b.settotal_percent(mi, fi, b.qiqi(qz1, qz2, qz3));
System.out.println("Student : " + a.getname());
System.out.println("Quizes : " + a.getquiz1() + " " + a.getquiz2()
+ " " + a.getquiz3());
System.out.println("Exams : " + a.getmidterm() + " " + a.getfinale());
System.out.println("Tot_score : "+ b.gettotal_percent());
}
}
*************************************************************************************************************
여기서 출력값이 Student 랑 Quizes는 제대로 나오는데 Tot_score가 출력값이 0.0 으로 나오는데 뭐가 문제임???
아 미치것네
댓글 영역
획득법
① NFT 발행
작성한 게시물을 NFT로 발행하면 일주일 동안 사용할 수 있습니다. (최초 1회)
② NFT 구매
다른 이용자의 NFT를 구매하면 한 달 동안 사용할 수 있습니다. (구매 시마다 갱신)
사용법
디시콘에서지갑연결시 바로 사용 가능합니다.