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;
}
}
2013년 2월 22일 금요일
피드 구독하기:
댓글 (Atom)
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...
-
Intel의 새로운 MMX - "KNI" KNI 는 Katmai New Instruction 의 약자이다 . 아는 분들은 잘 알고있겠지만 KATMAI( 이하 카트마이로 부름 ) 는 인텔의 다음번 펜티엄...
-
구글 문제 귀찮아서 이제 대충 뜻만... In a country in which people only want boys……every family continues to have children until they 남자만 원하는 나라가 있다...
-
[펌] [UNIX/LINUX 명령어] apropos linux 2005/06/28 22:05 수정 삭제 http://blog.naver.com/wiggyz/80014482910 Mr.You의 블로그 | ?? http:...
잘하눼~
답글삭제