Create a public class named: Employee that would get the firstname and lastname of each
employee from the keyboard/user
import java.util.Scanner;
class Employee {
private String lastName;
private String firstName;
public Employee(String lastName, String firstName) {
this.lastName = lastName;
this.firstName = firstName;
}
/**
* @return the lastName
*/
public String getLastName() {
return lastName;
}
/**
* @param lastName the lastName to set
*/
public void setLastName(String lastName) {
this.lastName = lastName;
}
/**
* @return the firstName
*/
public String getFirstName() {
return firstName;
}
/**
* @param firstName the firstName to set
*/
public void setFirstName(String firstName) {
this.firstName = firstName;
}
}
class App {
public static void main(String[] args) {
Scanner keyBoard = new Scanner(System.in);
System.out.print("Ente the last name: ");
String lastName = keyBoard.nextLine();
System.out.print("Ente the first name: ");
String firstName = keyBoard.nextLine();
Employee employee = new Employee(lastName, firstName);
System.out.println("The employee's last name: " + employee.getLastName());
System.out.println("The employee's first name: " + employee.getFirstName());
keyBoard.close();
}
}
Comments
Very Appreciated
Leave a comment