File tree Expand file tree Collapse file tree 2 files changed +110
-0
lines changed
samueledward/Question 3.0 Expand file tree Collapse file tree 2 files changed +110
-0
lines changed Original file line number Diff line number Diff line change
1
+ /*
2
+ * To change this license header, choose License Headers in Project Properties.
3
+ * To change this template file, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+ package classes ;
7
+
8
+ /**
9
+ *
10
+ * @author Samuel Edward
11
+ */
12
+ public class Employee {
13
+
14
+ private String firstName ;
15
+ private String lastName ;
16
+ private double salary ;
17
+
18
+ public Employee (String firstName , String lastName , double salary ) {
19
+ this .firstName = firstName ;
20
+ this .lastName = lastName ;
21
+ }
22
+
23
+ public String getfirstName () {
24
+ return firstName ;
25
+ }
26
+
27
+ public String getlastName () {
28
+ return lastName ;
29
+ }
30
+
31
+ public double getsalary () {
32
+ return salary ;
33
+ }
34
+
35
+ public void setFirstName (String firstName ) {
36
+ this .firstName =firstName ;
37
+ }
38
+
39
+ public void setLastName (String lastName ) {
40
+ this .lastName =lastName ;
41
+ }
42
+
43
+ public void setSalary (double salary ) {
44
+ this .salary =salary ;
45
+ }
46
+
47
+
48
+
49
+
50
+
51
+ }
Original file line number Diff line number Diff line change
1
+ /*
2
+ * To change this license header, choose License Headers in Project Properties.
3
+ * To change this template file, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+ package classes ;
7
+ import java .util .Scanner ;
8
+
9
+
10
+ /**
11
+ *
12
+ * @author Samuel Edward
13
+ */
14
+ public class EmployeeTest {
15
+
16
+ public static void main (String args []) {
17
+ String firstName , lastName ;
18
+ double salary ;
19
+
20
+ Scanner interger = new Scanner (System .in );
21
+ Scanner decimal = new Scanner (System .in );
22
+
23
+ System .out .print ("Enter the First Name: " );
24
+ firstName = interger .nextLine ();
25
+
26
+ System .out .println ("Enter the Last Name: " );
27
+ lastName = interger .nextLine ();
28
+
29
+ System .out .println ("Enter the salary: " );
30
+ salary = decimal .nextDouble ();
31
+
32
+ Employee em1 = new Employee (firstName , lastName , salary );
33
+
34
+
35
+ System .out .println ("The first name is: " + em1 .getfirstName ());
36
+ System .out .println ("The last name is: " + em1 .getlastName ());
37
+
38
+ if (salary >= 0 ) {
39
+ System .out .println ("The salary is: " + em1 .getsalary ());
40
+ } else {
41
+ System .out .println ("The salary is not valid" );
42
+ }
43
+ }
44
+ }
45
+
46
+
47
+
48
+
49
+
50
+
51
+
52
+
53
+
54
+
55
+
56
+
57
+ }
58
+
59
+ }
You can’t perform that action at this time.
0 commit comments