Answer to Question #328972 in Java | JSP | JSF for Amadix

Question #328972

Create a public class named: Employee that would get the firstname and lastname of each

employee from the keyboard/user


1
Expert's answer
2022-04-15T08:24:05-0400


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();


	}


}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

Amadix
19.04.22, 12:48

Very Appreciated

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS