다음과 같은 조건을 만족하는 프로그램을 작성 하시오
사원 관리에 대한 프로그램이다.
3명의 사원을 생성하고 각각의 연봉, 총 연봉의 평균을 구하는 프로그램이다.
해당 구현 클래스 다이어그램과 클래스 구조를 참고하여 프로젝트를 완성하시오.
- 프로젝트 명 :
07_ObjectArray_Homework_본인이름

* Employee의 setter/getter 메소드는 직접 구현한다.


[model/vo]
package com.hw1.model.vo;
public class Employee {
private int empNo;
private String empName;
private String dept;
private String job;
private int age;
private char gender;
private int salary;
private double bonusPoint;
private String phone;
private String address;
public Employee() {}
public Employee(int empNo, String empName, int age, char gender, String phone, String address) {
this.empNo = empNo;
this.empName = empName;
this.age = age;
this.gender = gender;
this.phone = phone;
this.address = address;
}
public Employee(int empNo, String empName, String dept, String job, int age, char gender, int salary,
double bonusPoint, String phone, String address) {
this.empNo = empNo;
this.empName = empName;
this.dept = dept;
this.job = job;
this.age = age;
this.gender = gender;
this.salary = salary;
this.bonusPoint = bonusPoint;
this.phone = phone;
this.address = address;
}
public int getEmpNo() {
return empNo;
}
public void setEmpNo(int empNo) {
this.empNo = empNo;
}
public String getEmpName() {
return empName;
}
public void setEmpName(String empName) {
this.empName = empName;
}
public String getDept() {
return dept;
}
public void setDept(String dept) {
this.dept = dept;
}
public String getJob() {
return job;
}
public void setJob(String job) {
this.job = job;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public char getGender() {
return gender;
}
public void setGender(char gender) {
this.gender = gender;
}
public int getSalary() {
return salary;
}
public void setSalary(int salary) {
this.salary = salary;
}
public double getBonusPoint() {
return bonusPoint;
}
public void setBonusPoint(double bonusPoint) {
this.bonusPoint = bonusPoint;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String information() {
return empNo + ", " + empName + ", " + dept + ", " + job + ", " + age + ", "
+ gender + ", " + salary + ", " + bonusPoint + ", " + phone
+ ", " + address;
}
}
[run]
package com.hw1.run;
import com.hw1.model.vo.Employee;
public class Run {
public static void main(String[] args) {
Employee ep = new Employee();
// 1. 객체배열을 크기 3으로 할당 한 뒤 3개의 생성자를 이용하여 각각 생성한 후 출력
Employee emp[] = new Employee[3];
emp[0] = new Employee(); // 기본생성자
emp[1] = new Employee(1, "홍길동", 19, 'M', "01022223333", "서울 잠실"); // 6개짜리 매개변수 생성자
emp[2] = new Employee(2, "강말순", "교육부", "강사", 20, 'F', 1000000, 0.01, "01011112222", "서울 마곡");
for(int i = 0; i < emp.length; i++) {
System.out.println("emp[" + i + "] : " + emp[i].information() );
}
System.out.println("========================================================");
// 2. 3개의 객체 중 값이 없는 필드에 각각 값을 넣고 출력
emp[0].setEmpNo(0);
emp[0].setEmpName("김말똥");
emp[0].setDept("영업부");
emp[0].setJob("팀장");
emp[0].setAge(30);
emp[0].setGender('M');
emp[0].setSalary(3000000);
emp[0].setBonusPoint(0.2);
emp[0].setPhone("01055559999");
emp[0].setAddress("전라도 광주");
emp[1].setDept("기획부");
emp[1].setJob("부장");
emp[1].setSalary(4000000);
emp[1].setBonusPoint(0.3);
System.out.println("emp[0] : " + emp[0].information() );
System.out.println("emp[1] : " + emp[1].information() );
System.out.println("========================================================");
// 3. 직원 각각의 보너스가 적용된 1년 연봉을 계산하여 출력
// 연봉 = ( 급여 + (급여 * 보너스포인트 )) * 12
int sum = 0;
for(int i=0; i < emp.length; i++) {
int sumSalary = (int) (emp[i].getSalary() + (emp[i].getSalary() * emp[i].getBonusPoint()) ) * 12;
System.out.println(emp[i].getEmpName() + "의 연봉 : " + sumSalary + "원");
sum += sumSalary;
}
System.out.println("========================================================");
// 4. 세 직원의 연봉 평균을 구하여 출력
// 위의 3번에서 sum 변수 이용하여 평균을 냄
System.out.println("직원들의 연봉의 평균 : " + sum / emp.length + "원");
}
}