hello ... here's the question ... its divided in Part A, B and C
Part A. Page 400 Programming Exercise #1 – “Employee” Class
Use the Test Data given in the book. These values should be read in from a user within code that is in “main”. For example, I should NOT see “Susan Meyers” anywhere in your code.
Exercise 1. Employee Class
Write a class named Employee tha has the following fields:
name. The name field references a String object that holds the employee’s name.
idNumber. The idNumber is XXXXX int variable that holds the employee’s name.
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 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 that creates three Employee objects to hold the following data:
Name ID Number Department Position
Susan Meyers 47899 Accounting Vice President
XXXXX XXXXX 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 on the screen.
Part B. Extend what you wrote for Part A - Change the Class Name to “EmployeeB”
Add another Data Member: “salary” - a double representing money - 2 decimal places.
Update the methods in the class to accommodate this new data member.
Add another method: “toString()” that returns a String with all of the data in it.
Update “main” to accommodate the “salary”. During the run, you make up data values.
This is NOT in Chapter 6.
“toString” starts on Page 509
Please take notes in class!
Update the printing in “main” to use “toString()”
( I.e. main’s “System.out.println” should just use
the name of a “EmployeeB” object! )
Part C. Page 402 Programming Exercise #7 – “Circle” Class
Create 4 circles in “main” with these Radius Values: 10, 15.2, 0, 25.5
Create the first two circles by using the constructor that accepts a radius value as a parameter.
Create the last two circles by using the “no-arg” constructor and a mutator method.
In main, after creating all 4 circles, print these things for each of the 4 circles:
The circle’s radius, area, diameter and circumference.
Exercise 7. Circle Class
Write a Circle class that has the following fields:
Radius: a double
PI: a final doubleinitialized withthe value 3.14159
The class should have the following methods:
Contructor. Accepts the radius of the circle as an argument.
Constructor. A no-arg constructor that sets the radius field to 0.0.
setRadius. A mutator method for the radius field.
getRadius. An accessor method for the radius field.
getArea. Returns the area of the circle, which is calculated as
area = PI * radius * radius
getDiameter. Returns the diameter of the circle, which is calculated as
diameter = radius * 2
getCircumference. Returns the circumference of the circle, which is calculated as
circumference = 2 * PI * radius
Write a program that demonstrate the Circle class by asking the user for the circle’s radius, creating a Circle object, and then reporting the circle’s area, diameter, and circumference.
Special Instructions For Lab#2
Please, do NOT use an array of objects for any of these exercises.
Please notice where it says what should be done in “main”: it could be done in another static method that “main” calls - but, it is NOT done within any of your non-static methods inside the class that is instantiated.
IMPORTANT: Do NOT name any of your formal parameters in “Employee” class, “EmployeeB” class or “Circle” class with the same name as any of your instance fields!!
Special Instructions For Parts A & B ( Class “Employee” and “EmployeeB” )
Employee class has:
* private instance fields
* a “no-arg” constructor ( as defined in the problem )
* 2 other constructors defined in the problem that take parameters
* accessor methods for each instance field (e.g. getName)