Write a class called employee that has the following fields

Assignment Help Basic Computer Science
Reference no: EM13308190

Write a class called Employee that has the following fields:

? name - the name field references 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 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:

o 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.

o A no-argument constructor that assigns empty strings ("") to the name, department, and position fields and 0 to the idNumber field.

Also write appropriate accessor and mutator methods for each field.

Finally, write an appropriate toString() method that prints the state of the object. Example: Name: Mark Jones ID Number: 39119 Department: IT Position: Programmer

 

/*

 

For this program, you should write:

- A constructor that initializes the fields

1) name

2) ID

3) department

4) position

- A no argument constructor

- Mutator methods for each field

 

*/

import java.util.*;

 

public class Lab12Driver

{

public static void main(String [] args)

{

Scanner inScan=new Scanner(System.in);

// Reads the name

System.out.println("Enter employee's Name: ");

String name=inScan.nextLine();

// Reads the ID Number

System.out.println("Enter employee's ID Number: ");

int ID=inScan.nextInt();

// Om nom nom

// Flush the buffer

inScan.nextLine();

// Reads the department

System.out.println("Enter employee's department: ");

String dept=inScan.nextLine();

// Reads the position

System.out.println("Enter employee's position: ");

String pos=inScan.nextLine();

// Use the constructor

Employee firstGuy=new Employee(name,ID,dept,pos);

System.out.println(firstGuy);

// Use the empty constructor

Employee emptyGuy=new Employee();

// Use the mutator methods to fill the fields

emptyGuy.setName("Fred");

emptyGuy.setID(9001);

emptyGuy.setDepartment("Fred");

emptyGuy.setPosition("Underwater Basket Weaver");

System.out.println(emptyGuy);

}

}

 

Reference no: EM13308190

Questions Cloud

How many hits does the sequence exhibit : Assume LRU replacement policy, for each sequence, how many hits does the sequence exhibit?
Explain digital computing/networking in major organizations : Identify and discuss at least three major evolutionary steps in digital computing/networking experienced in major organizations. If possible, provide such insight regarding your current or former organization.
How many data in the number of bytes can be hold in cache : What is the size of the cache, i.e., how many data in the number of bytes can be hold in the cache?
How much does the water in the cloud weigh in pounds : Often this content is measured in grams per cubic meter (g/m3). Assume that a cumulus cloud occupies a volume of one cubic kilometer, and its liquid water content is 0.210 g/m3.
Write a class called employee that has the following fields : Finally, write an appropriate toString() method that prints the state of the object. Example: Name: Mark Jones ID Number: 39119 Department: IT Position: Programmer
Determine the required are of concrete for the thrust block : Given that the max shear strength of the the concrete shore is 10 kPa and the engineer requires a F.S. of 2.5, find the required are of concrete for the thrust block.
Determine what is the pressure in the pipe at floor level : A water storage tank is on the roof of a factory building & the surface of the water is 50 ft above the floor of the factory. if a pipe connects the storage tank to the floor level & the pipe is full of static water
Declare a variable : Assume the existence of a Window class with methods getWidth and getHeight, and a subclass TitledWindow, with a constructor accepts a string corresponding to the title of the window.
Find the expected number of jobs in the system at any time : An M/M/1 queuing system spends 30% of the time in the idle state. Find the expected number of jobs in the system at any time.

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Making the row number absolute

In cell F6, create a formula to calculate the Total with Insurance. Multiply E6 by 1+ the insurance to calculate the result. Enter the insurance rate as a mixed cell reference in the formula, making the row number absolute.

  How these models would facilitate a company in the country

Review the IT diffusion models, select two models, then compare and contrast how these models would facilitate a company in the country and business sector of your choice. Be sure to state your business sector. Then, explain how the IT diffusion m..

  Responsibility to maintain ethical standard in department

Do managers have a responsibility to maintain an ethical standard within a department? If so, how is the expected ethical standard established? How is it documented? How is compliance measured?

  Describe how the referential integrity restrict

Describe how the referential integrity restrict, cascade, and set-to-null delete rules operate in a relational database

  Write a phone book program

When phone book enties are displayed all data members will be displayed. Create a friend function that overloads the

  Describe the graphical coordinate system in java

How do you specify a particular color to be used as fill when using the Graphics class?

  Discuss how the it department helps the organization achieve

Discuss how the IT department helps the organization achieve their strategic goals

  How easy or difficult would it be to initiate such advantage

More generally, to what extent do specific technologies help companies gain an edge over their competitors? How easy or difficult would it be to initiate such advantages?

  Follow-up actions for making decisions

What are the things you should consider in making this decision, and based on your choice, what would be your follow-up actions?

  Explaining multiple client computers and servers

In network with multiple client computers, servers, switches and wireless access points, write down resources must be scanned for possible vulnerabilities.

  Multimedia application between two multimedia applications

If your running memory intensive multimedia application on the computer which has 128 MB RAM installed and computer is momentarily stopping when you switch between two multimedia applications.

  Advantages and disadvantages of asymmetric or symmetric key

The Institute has collaborated with XYZ inc. for research on genetics. Information should be kept top secret at any cost. At ABC Institute, researchers are not sure about kind of key.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd