-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathEmployeeTest.java
More file actions
135 lines (96 loc) · 3.8 KB
/
EmployeeTest.java
File metadata and controls
135 lines (96 loc) · 3.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
import java.util.*;
class Employee{
String first_name,last_name;
double monthlysalary,yearlysalary;
Employee(){
first_name = "";
last_name = "";
monthlysalary = 0.0;
yearlysalary = 0.0;
}
void setFirstName(String first_name){
this.first_name = first_name;
}
void setLastName(String last_name){
this.last_name = last_name;
}
void setMonthlySalary(double salary){
if(salary<0){
this.monthlysalary = 0.0;
}
else{
this.monthlysalary = salary;
}
}
void setYearlySalary(double yearlysalary){
this.yearlysalary = yearlysalary;
}
String getFirstName(){
return first_name;
}
String getLastName(){
return last_name;
}
String getFullName(){
return (first_name + " "+last_name);
}
double getMonthlySalary(){
return monthlysalary;
}
double getYearlySalary(){
return yearlysalary;
}
}
class Employee_Test{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
Employee employee_1 = new Employee();
Employee employee_2 = new Employee();
System.out.println("-:Enter First Employee Details:- ");
System.out.print("Enter First Name:- ");
String first_name = sc.next();
System.out.print("Enter Last Name:- ");
String last_name = sc.next();
System.out.print("Monthly Salary:- ");
double salary = sc.nextDouble();
employee_1.setFirstName(first_name);
employee_1.setLastName(last_name);
employee_1.setMonthlySalary(salary);
System.out.println("-:Enter Second Employee Details:- ");
System.out.print("Enter First Name:- ");
String first_name1 = sc.next();
System.out.print("Enter Last Name:- ");
String last_name1 = sc.next();
System.out.print("Monthly Salary:- ");
double salary1 = sc.nextDouble();
employee_2.setFirstName(first_name1);
employee_2.setLastName(last_name1);
employee_2.setMonthlySalary(salary1);
System.out.println("-:Details of Employees:-");
System.out.println("Employee 1: ");
System.out.println("Full Name:- "+employee_1.getFullName());
System.out.println("Monthly Salary:- "+employee_1.getMonthlySalary());
System.out.println("-------------------------------");
System.out.println("Employee 1: ");
System.out.println("Full Name:- "+employee_2.getFullName());
System.out.println("Monthly Salary:- "+employee_2.getMonthlySalary());
System.out.println("-------------------------------");
System.out.println("-:Employees Yearly Salary After 10% Increment");
double e1_ten_p = (employee_1.getMonthlySalary()) * 0.10;
employee_1.setMonthlySalary(employee_1.getMonthlySalary()+e1_ten_p);
double yearlysalary1 = (employee_1.getMonthlySalary()*12);
employee_1.setYearlySalary(yearlysalary1);
double e2_ten_p = (employee_2.getMonthlySalary()) * 0.10;
employee_2.setMonthlySalary(employee_2.getMonthlySalary()+e2_ten_p);
double yearlysalary2 = (employee_2.getMonthlySalary()*12);
employee_2.setYearlySalary(yearlysalary2);
System.out.println("Employee 1:- ");
System.out.println("Full Name:- "+employee_1.getFullName());
System.out.println("Monthly Salary: "+employee_1.getMonthlySalary());
System.out.println("Yearly Salary:- "+employee_1.getYearlySalary());
System.out.println("Employee 2:- ");
System.out.println("Full Name:- "+employee_2.getFullName());
System.out.println("Monthly Salary: "+employee_2.getMonthlySalary());
System.out.println("Yearly Salary:- "+employee_2.getYearlySalary());
}
}