Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a class named Employee that has the following fields: • name : The name fi

ID: 3670059 • Letter: W

Question

Write a class  named Employee that has the following fields:
• name : The name field is a String  object that holds the employee's name .
• idNumber: The idNumber is an int  variable that holds the employee's ID number.
• department: The department field is a String  object that holds the name of the department where the employee works.
• position: the position field is a string  object that holds the employee's job title.

Write appropriate mutator methods that store the values in these fields and accessor methods that return thevalues in these fields.

Once you have written the class , write a separate
program that creates three Employee objects to hold the following data:

Name ID Number Department Position
Susan Meyers 47899 Marketing Sales Rep
Mark Jones 39119 IT Programmer
Joy Rogers 81774 Manufacturing Engineer

The program should store this data in the three objects and then display the data
for each employee in the format:

Name , employee number ID Number, works as a Position in Department.

For example:

Susan Meyers, employee 47899, works as a Sales Rep in Marketing.

Print each statement on a separate line in the order Susan, Mark, Joy.

SAMPLE RUN #0: java Employee

the code i wrote:

public class Employee
       {
           // fields
           private String name;
           private int idnumber;
           private String department;
           private String position;
          
           // Constructors
           public Employee(String nm, int id, String dp, String ps)
           {
               name = nm;
               idnumber = id;
               department = dp;
               position = ps;
           }
          
           public Employee(String nm, int id)
           {
               name = nm;
               idnumber = id;
               department = " ";
               position = " ";  
           }
          
           public Employee()
           {
               name = " ";
               idnumber = 0;
               department = " ";
               position = " ";  
           }
          
           // Methods
           public String getName()
           {
               return name;
           }
          
           public int getIdnumber()
           {
               return idnumber;
           }
          
           public String getDepartment()
           {
               return department;
           }
      
       public String getPosition()
       {
           return position;
       }
              
       }
class EmployeeFile
{
   public static void main(String[] args)
   {
      
       //Different Employee instances.
       Employee box = new Employee("Susan Meyers", 47899, "Accounting", "Vice Pres");
       Employee box1 = new Employee("Mark Jones", 39119, "IT", "Programmer");
       Employee box2 = new Employee("Joy Rodgers", 81774, "Manufacturing", "Engineer");
      
       System.out.println(" Name       ID Number   Department   Position   ");
       System.out.println("_______________________________________________________");
       System.out.print(" " + box.getName() + "   " + box.getIdnumber() + "       " + box.getDepartment());
       System.out.println("   " + box.getPosition());
       System.out.print(" " + box1.getName() + "   " + box1.getIdnumber() + "       " + box1.getDepartment());
       System.out.println("           " + box1.getPosition());
       System.out.print(" " + box2.getName() + "   " + box2.getIdnumber() + "       " + box2.getDepartment());
       System.out.println(" " + box2.getPosition());
   }
  


}

Problems Detected:
          The contents of your standard output is incorrect.
          Failed 1 out of 1 test runs.

Failed Test Run


          The contents of your standard output is incorrect.

the error i got

Explanation / Answer

Hi, Your program is working fine. There is any error. I have tested. It is producing desire output.

class Employee
        {
            // fields
            private String name;
            private int idnumber;
            private String department;
            private String position;
          
            // Constructors
            public Employee(String nm, int id, String dp, String ps)
            {
                name = nm;
                idnumber = id;
                department = dp;
                position = ps;
            }
          
            public Employee(String nm, int id)
            {
                name = nm;
                idnumber = id;
                department = " ";
                position = " ";  
            }
          
            public Employee()
            {
                name = " ";
                idnumber = 0;
                department = " ";
                position = " ";  
            }
          
            // Methods
            public String getName()
            {
                return name;
            }
          
            public int getIdnumber()
            {
                return idnumber;
            }
          
            public String getDepartment()
            {
                return department;
            }
      
        public String getPosition()
        {
            return position;
        }
              
        }
class EmployeeFile
{
    public static void main(String[] args)
    {
      
        //Different Employee instances.
        Employee box = new Employee("Susan Meyers", 47899, "Accounting", "Vice Pres");
        Employee box1 = new Employee("Mark Jones", 39119, "IT", "Programmer");
        Employee box2 = new Employee("Joy Rodgers", 81774, "Manufacturing", "Engineer");
      
        System.out.println(" Name          ID Number      Department      Position    ");
        System.out.println("_______________________________________________________");
        System.out.print(" " + box.getName() + "    " + box.getIdnumber() + "          " + box.getDepartment());
        System.out.println("      " + box.getPosition());
        System.out.print(" " + box1.getName() + "      " + box1.getIdnumber() + "          " + box1.getDepartment());
        System.out.println("              " + box1.getPosition());
        System.out.print(" " + box2.getName() + "     " + box2.getIdnumber() + "          " + box2.getDepartment());
        System.out.println("   " + box2.getPosition());
    }   
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote