2013년 2월 22일 금요일

5일차 - 숙제해결 ㅠㅠ

public class StudentMain {

public static void main(String[] args){
//1.학생객체생성
//2.학생객체 데이타셋팅(점수,이름,학번)
//3.총점,평균,평점구하기
//4.학생객체데이타 출력

Student st = new Student();

st.setData("haha",1,60,50,70);
st.tot();
st.avg();
st.grad();
st.print();





}


}
-------------------------------------------

public class Student {
public String no ;
public int undergrad ;
public int kor ;
public int eng ;
public int math ;
public int tot ;
public int avg ;
public char grad ;

public void tot(){
this.tot=this.kor+this.eng+this.math;
}
public void avg(){
this.avg=tot/3;
}
public void grad(){
char hakjum=' ';
if(this.avg>=90){
hakjum ='a';

}else if(this.avg>=80){
hakjum ='b';
}else if(this.avg>=70){
hakjum ='c';
}else if(this.avg>=60){
hakjum ='d';
}else if(this.avg>=50){
hakjum ='e';
}
this.grad=hakjum;
}


public void setData(String no, int undergrad, int kor, int eng, int math){
this.no=no;
this.undergrad=undergrad;
this.kor=kor;
this.eng=eng;
this.math=math;

}
public void print(){
System.out.println("이름"+this.no);
System.out.println("학번"+this.undergrad);
System.out.println("국어"+this.kor);
System.out.println("영어"+this.eng);
System.out.println("수학"+this.math);
System.out.println("총점"+this.tot);
System.out.println("평균"+this.avg);
System.out.println("평점"+this.grad);

}

public int tot1(int a, int b, int c){
return a+b+c;
}
public  int avg1(int a){
return (tot/3);
}
public  int grad1(int a){
char hakjum=' ';
if(avg<0 || avg>100){
if(avg>=90){
hakjum ='a';

}else if(avg>=80){
hakjum ='b';
}else if(avg>=70){
hakjum ='c';
}else if(avg>=60){
hakjum ='d';
}else if(avg>=50){
hakjum ='e';
}

};
return hakjum;
}


}

댓글 1개:

국정원의 댓글 공작을 지탄합니다.

UPBIT is a South Korean company, and people died of suicide cause of coin investment.

 UPBIT is a South Korean company, and people died of suicide cause of coin. The company helps the people who control the market price manipu...