1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Step2247 [10]
3 years ago
14

Use Java to write a class named Employee that has the following fields: name - The name field references a String object that ho

lds the employee's name; idNumber - The idNumber is an int variable that holds the employee's ID number department; department - The department field references a String object that holds the name of the department where the employee works; position - The position field references a String object that holds the employee's job title.
The class should have the following constructors: 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. A constructor that accepts the following values as arguments and assigns them to the appropriate fields: employee's name and ID number. The department, and position fields should be assigned an empty string (" "). A no-arg constructor that assigns empty strings (" ") to the name, department, and position fields, and 0 to the idNumber field.

Write appropriate mutator methods that store values in these fields and accessor methods that return the values in these fields. Once you have written the class, write a separate program the creates three Employee objects to hold the following data: Name ID Number Department Position Susan Meyers 47899 Accounting Vice President Mark Jones 39119 IT Programmer Joy Rogers 81774 Manufacturing Engineer.

The program should store this data in three objects and then display the data for each employee on the screen.
Computers and Technology
1 answer:
myrzilka [38]3 years ago
8 0

Answer:

Hi Mitutk! Very good question for Java programmers to test knowledge on classes, constructors and mutator methods. Please find the answer with explanation below.

Explanation:

Constructors in Java can be declared with different parameters. Declaring the properties of the Employee object as private, such as the name, id, department and position as in this example, is good design practice as it helps to keep data secure. We can get and set these properties by accessor methods as declared below. The second program can be written a few different ways, try using the set methods for storing the different info instead of the constructors used.

 

Employee.java

class Employee {

 private String employeeName;

 private int idNumber;

 private String department;

 private String position;

 public Employee() {

   employeeName = "";

   idNumber = 0;

   department = "";

   position = "";

 }

 public Employee(String name, int id, String dept, String pos) {

   employeeName = name;

   idNumber = id;

   department = dept;

   position = pos;

 }

 public Employee(String name, int id) {

   employeeName = name;

   idNumber = id;

   department = "";

   position = "";

 }

 public void set_employee_name(String empName) {

   employeeName = empName;

 }

 public String get_employee_name() {

   return employeeName;

 }

 public void set_employeeId(int empId) {

   idNumber = empId;

 }

 public int get_employeeId() {

   return idNumber;

 }      

       

 public void set_department(String dept) {

   department = dept;

 }          

 public String get_department() {

   return department;

 }

   

 public void set_position(String pos) {

   position = pos;

 }

   

 public String get_position() {

   return position;

 }

}

EmployeeProgram.java

import Employee.java;

public class EmployeeProgram {

 public static void main(String args[]) {

   Employee emp1 = new Employee("Susan Meyers", 47899, "Accounting", "Vice President");

   Employee emp2 = new Employee("Mark Jones", 39119, "IT", "Programmer");

   Employee emp3 = new Employee("Joy Rogers", 81774, "Manufacturing", "Engineer");

   System.out.println(emp1.get_employee_name());

   System.out.println(emp2.get_employee_name());

   System.out.println(emp3.get_employee_name());

 }

}

You might be interested in
Search engines enable you to
docker41 [41]
The answer is easily <span>locate Web pages related to a specific subject.</span>
6 0
3 years ago
Read 2 more answers
Vector graphics are composed of solid __________,curves and other __________ shapes​
serious [3.7K]

Answer:

Lines; geometric.

Explanation:

Graphic design can be defined as an artistic process used for the creation of art works such as logos.

In the creation of various graphic files such as in 2-D or 3-D we can use a variety of software applications or programs such as Blender basics, Adobe photoshop, illustrator, Coreldraw, etc.

Graphic design involves the use of vector graphics, bitmap graphics or raster graphics.

Vector graphics are composed of solid lines, curves and other geometric shapes that are typically defined by series of mathematical instructions. Thus, vector graphics can be scaled to a smaller or larger size without any change in its quality.

5 0
3 years ago
What is a BUG in terms of computer programming?
diamong [38]

Answer:

C

Explanation:

4 0
3 years ago
Effectiveness of thicker,biodegradable plastic shopping bags
juin [17]

The Effectiveness of thicker, biodegradable plastic shopping bags is that they can last for a long time and still be able to carry shopping items  even if they are exposed to natural environment.

<h3>What is the use of biodegradable plastic bags?</h3>

Plastic bags are known to be part of modern technology. They are usually very  thin and strong. They are able to carry a heavy load as a result of shopping.

Conclusively, Note that this type of plastic bags which are said to be biodegradable can last for a long time and still be able to carry shopping items  even if they are exposed to natural environment.

Learn more about bags from

brainly.com/question/728465

4 0
3 years ago
Which button is used to set up the pen color?
Mrac [35]
C. custom slideshow because this is where you can customise everything you do eg. pen colour, don't etc.
5 0
4 years ago
Read 2 more answers
Other questions:
  • What are three methods of sustainable farming and describe each.
    9·1 answer
  • Branching is so called because <br>​
    5·2 answers
  • What is a good monitor for console gaming? (Any price)
    13·2 answers
  • The domain in an email message tells you what?
    11·1 answer
  • ______ is the software that prevents people from being able to access your personal information.
    8·2 answers
  • WILL GIVE BRAINLIEST TO HELPFUL ANSWERS!
    8·1 answer
  • What does "scanf(\"%d\" mean?
    13·2 answers
  • 5. Which one of these can connect directly to the internet?
    9·2 answers
  • Power Supply<br><br> Description :
    14·1 answer
  • PLEASE HELP URGENT!!
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!