콩쓰s 2014. 5. 12. 17:17

문제 요약

1> 교육생 클래스에는 이름, 소속, 과정명, 교육비, 환급금 5개 변수

소속 --> KITRI (static)

2> .main() 메서들르 포함하는 클래스 작성. student 라는 이름의 변수로 참조하도록 한다.

3> 명령행 매개변수를 이용하여 사용자로부터 student가 참조하는 객체의 이름, 과정명, 교육비를 입력받아서 변수를 초기화한다.

4> 환급금은 과정명이 "자바프로그래밍"이면 입력한 교육비의 25%이고

과정명이 JDBC 프로그래밍이면 입력한 교육비의 20%이고,

과정명이 JSP 프로그래밍이면 입력한 교육비의 15%이고,

그밖의 과정명은 잘못입력되었습니다. 에러메시지를 출력한다.

 

student내의 이름, 소속, 과정명, 교육비, 환급금을 출력합니다.


 

class education{
 String name;
 static String group = "KITRI";
 String course;
 int cost;
 int result;
 }

public class JavaTest {
 public static void main(String[] args) {
  education student = new education();
  student.name = args[0];
  student.course = args[1];
  student.cost = Integer.parseInt(args[2]);
 
  if(student.course.equals("java")){
   student.result = (int) (student.cost * 0.25);
   System.out.println(args[0]+" 학생은 "+student.group+"에서 "+args[1]+" 과정을 듣고 있으며 이 과목의 수강료는 "+student.cost+"원이고 환급금은 "+student.result+"입니다.");
  }
  else if(student.course.equals("jdbc")){
   student.result = (int)(student.cost * 0.20);
   System.out.println(args[0]+" 학생은 "+student.group+"에서 "+args[1]+" 과정을 듣고 있으며 이 과목의 수강료는 "+student.cost+"원이고 환급금은 "+student.result+"입니다.");
  }
  else if(student.course.equals("jSP")){
   student.result = (int)(student.cost * 0.15);
   System.out.println(args[0]+" 학생은 "+student.group+"에서 "+args[1]+" 과정을 듣고 있으며 이 과목의 수강료는 "+student.cost+"원이고 환급금은 "+student.result+"입니다.");
  }
  else{
   System.out.println("잘못 입력하셨습니다. ");
  }
 }

}

 


JavaTest.java