Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

// Later in the program // Display info for each employee e1.outputEmployeeInfo(); e2.outputEmployeeInfo(); e3.outputEmployeeInfo(); e4.outputEmployeeInfo(); // etc. } code given: public class employee { private

image text in transcribed

// Later in the program

// Display info for each employee

e1.outputEmployeeInfo();

e2.outputEmployeeInfo();

e3.outputEmployeeInfo();

e4.outputEmployeeInfo();

// etc.

}

code given:

public class employee {

private String name, department, position; private int idNumber;

public String outputEmployeeInfo() { System.out.println("Employee:" + name + "-ID:" + idNumber + " -Department:" + department + "-Position:" + position); return "Employee:" + name + "-ID:" + idNumber + "-Department:" + department + "-Position:" + position; }

public static void main(String[] args) { employee employee1 = new employee(); employee1.name = "Susan Meyers "; employee1.idNumber = 47899; employee1.department = "Accounting "; employee1.position = "Vice President ";

employee employee2 = new employee(); employee2.name = "Mark Jones "; employee2.idNumber = 39119; employee2.department = "It "; employee2.position = "Programmer ";

employee employee3 = new employee(); employee3.name = "Joy Rogers "; employee3.idNumber = 81774; employee3.department = "Manufacturing "; employee3.position = "Engineer ";

employee1.outputEmployeeInfo(); employee2.outputEmployeeInfo(); employee3.outputEmployeeInfo();

} }

3. Employee class constructors and methods, Based on Gaddis Programming Challenges 6.1. (10 points) Modify the Employee class from the previous problem to add overloaded constructors: A no-arg constructor that assigns empty strings(") to the name, department, and position fields, and 0 to the idNumber field . A constructor that accepts an employee's name and ID number an assigns them to appropriate fields. The department and position fields should be assigned an empty string ("") .A constructor that accepts the following values as arguments and assigns them to the appropriate fields: employee's name, employee's ID number, department, and position Add a new method "outputmployeelnfo" to display all employee information on-screen using Svstem.out.printLn Use the new constructors to create employees and display their data The employee data to create No-arg constructor: Name Van Tyler Diana Wells Kate Dixon ID Number Department 74525 35258 81485 Accounting IT Manufacturing Position Vice President Programmer Engineer Employee name and ID constructor: 12579 Oliver Mills Robert Goodman Linda Cunningham 58255 Accounting IT Manufacturing Vice President Programmer Engineer 96485 All-fields constructor: Kendra Beck Cathy Mckinne Irvin Warren 75956 39858 58525 Accounting IT Manufacturing Vice President Programmer Engineer Use the outputinfo() method for each employee object to display the information on screen. For example: Employee e4 = new Employee ("Oliver Mills", 12579); e4.department "Accounting"; e4.po3ition = "vice Pre3ident

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Real Time Database Systems Architecture And Techniques

Authors: Kam-Yiu Lam ,Tei-Wei Kuo

1st Edition

1475784023, 978-1475784022

More Books

Students also viewed these Databases questions