Java Proje: Employee (OOP)
public class Main2 {
public static void main(String[] args) {
Employee employer1= new Employee("Hasan" , 2000,8,2000);
Employee employer2= new Employee("Ayşe" , 1700,9,2020);
Employee employer3= new Employee("Aziz" , 800,10,2016);
Employee employer4= new Employee("Ceren" , 1200,9,2010);
Employee employer5= new Employee("Sude" , 900,8,2009);
System.out.println("Name:" + employer1.name);
System.out.println("Salary:" + employer1.salary);
System.out.println("Work Hours:" + employer1.workHours);
System.out.println("Hire Year:" + employer1.hireYear);
employer1.Tax();
employer1.BonusMethod();
employer1.workingYear();
System.out.println("-------------");
System.out.println("Name:" + employer2.name);
System.out.println("Salary:" + employer2.salary);
System.out.println("Work Hours:" + employer2.workHours);
System.out.println("Hire Year:" + employer2.hireYear);
employer2.Tax();
employer2.BonusMethod();
employer2.workingYear();
System.out.println("-------------");
System.out.println("Name:" + employer3.name);
System.out.println("Salary:" + employer3.salary);
System.out.println("Work Hours:" + employer3.workHours);
System.out.println("Hire Year:" + employer3.hireYear);
employer3.Tax();
employer3.BonusMethod();
employer3.workingYear();
System.out.println("-------------");
System.out.println("Name:" + employer4.name);
System.out.println("Salary:" + employer4.salary);
System.out.println("Work Hours:" + employer4.workHours);
System.out.println("Hire Year:" + employer4.hireYear);
employer4.Tax();
employer4.BonusMethod();
employer4.workingYear();
System.out.println("-------------");
System.out.println("Name:" + employer5.name);
System.out.println("Salary:" + employer5.salary);
System.out.println("Work Hours:" + employer5.workHours);
System.out.println("Hire Year:" + employer5.hireYear);
employer5.Tax();
employer5.BonusMethod();
employer5.workingYear();
}
}
public class Employee {
public String name;
public double salary;
public double workHours;
public int hireYear;
Employee(String name, double salary, double workHours, int hireYear) {
this.name = name;
this.salary = salary;
this.workHours = workHours;
this.hireYear = hireYear;
}
public void Tax() {
if (salary <= 1000) {
System.out.println("Maaşı: " + salary);
} else {
double taxAccount = (double) (salary * 3 / 100);
double newSalary = (double) (salary - taxAccount);
System.out.println("Maaşı:" + newSalary);
}
}
public void BonusMethod() { // en fazla 3 saat mesaiye kalınabilir.
if(workHours-8==1) {
System.out.println("Mesaiye kaldı");
double shift=(double)(salary+30);
double totalyEarning=(double)(salary+shift);
System.out.println("Maaşı:"+ totalyEarning);
}
else if(workHours-8==2){
System.out.println("Mesaiye kaldı");
double shift=(double)(salary+60);
double totalyEarning=(double)(salary+shift);
System.out.println("Maaşı:"+ totalyEarning);
}
else if(workHours-8==3){
System.out.println("Mesaiye kaldı");
double shift=(double)(salary+90);
double totalyEarning=(double)(salary+shift);
System.out.println("Maaşı:"+ totalyEarning);
}
else {
System.out.println("Mesaiye kalmadı");
System.out.println("Maaşı:" + salary);
}
}
public void workingYear(){
if( 2023-hireYear<10){
double interest=(double)(salary*5/100);
double interestSalary =(double) (interest+salary);
System.out.println("Zamlı Maaş:" + interestSalary);
}
else if(2023-hireYear<=19 && 2023-hireYear>9){
double interest=(double)(salary*10/100);
double interestSalary =(double) (interest+salary);
System.out.println("Zamlı Maaş:" + interestSalary);
}
else if(2023-hireYear>=20){
double interest=(double)(salary*15/100);
double interestSalary =(double) (interest+salary);
System.out.println("Zamlı Maaş:" + interestSalary);
}
}
}
Yorumlar
Yorum Gönder