-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
61 lines (49 loc) · 1.74 KB
/
Main.java
File metadata and controls
61 lines (49 loc) · 1.74 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
import java.util.Scanner;
class person {
private String firstName;
private String lastName;
public person(String firstName, String lastName) {
this.firstName = firstName;
this.lastName = lastName;
}
public String getFirstName(){
return firstName;
}
public String getLastName(){
return lastName;
}
}
class employee extends person{
private String employeeId;
private String jobTitle;
public employee(String firstName, String lastName, String employeeId, String jobTitle){
super(firstName, lastName);
this.employeeId = employeeId;
this.jobTitle = jobTitle;
}
public String getEmployeeId(){
return employeeId;
}
public String getLastName() {
return super.getLastName() + ", " + jobTitle;
}
}
public class Main{
public static void main(String[] args){
Scanner scanner = new Scanner(System.in);
System.out.println("Enter your 1st name: ");
String firstName = scanner.nextLine();
System.out.print("Enter last name: ");
String lastName = scanner.nextLine();
System.out.print("Enter employee ID: ");
String employeeId = scanner.nextLine();
System.out.print("Enter job title: ");
String jobTitle = scanner.nextLine();
employee emp = new employee(firstName, lastName, employeeId, jobTitle);
System.out.println("Employee Details:");
System.out.println("First Name: " + emp.getFirstName());
System.out.println("Last Name: " + emp.getLastName()); // Will include job title
System.out.println("Employee ID: " + emp.getEmployeeId());
scanner.close();
}
}