Answer to Question #336107 in Java | JSP | JSF for dfscss

Question #336107

Create a class called Employee to represent the details of an Employee. a) Include the following data members to the Employee class. EmpId, name, address (all are string data) b) Your class should have a constructor that initializes all instance variables. c) Include a method called void Read() which will input the above values from the keyboard d) Include a method called void Print() to display the properties


1
Expert's answer
2022-05-02T13:37:23-0400

public class Employee {


  private String emplId;

  private String name;

  private String address;


  public Employee(String emplId, String name, String address) {

    this.emplId = emplId;

    this.name = name;

    this.address = address;

  }


  public void read() {

    Scanner scanner = new Scanner(System.in);

    System.out.println("Empl ID:");

    this.emplId = scanner.nextLine();

    System.out.println("name:");

    this.name = scanner.nextLine();

    System.out.println("address:");

    this.address = scanner.nextLine();

    scanner.close();

  }


  public void print() {

    System.out.println("Empl ID: " + this.emplId +

        " name: " + this.name +

        " address: " + this.address);

  }

}


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

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS