Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java language 1. Employee Class Write a class named Employee that has the following fields: name. The name field references a string object that holds

Java language image text in transcribed
image text in transcribed
image text in transcribed
1. Employee Class Write a class named 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: 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 pro- gram that creates three Employee objects to hold the following data: ID Number Name Susan Meyers Mark Jones Joy Rogers 47899 39119 81774 Department Accounting IT Manufacturing Position Vice President Programmer Engineer The program should store this data in the three objects and then display the data for each employee on the screen. 2. Car Class Write a class named Car that has the following fields: yearModel. The yearModel field is an int that holds the car's year model. make. The make field references a string object that holds the make of the car. speed. The speed field is an int that holds the car's current speed. Programming Challenges In addition, the class should have the following constructor and other methods. Constructor. The constructor should accept the car's year model and make as argu- ments. These values should be assigned to the object's yearModel and make fields. The constructor should also assign 0 to the speed field. Accessors. Appropriate accessor methods should get the values stored in an object's year Model, make, and speed fields. accelerate. The accelerate method should add 5 to the speed field each time it is called. brake. The brake method should subtract from the speed field each time it is called. Demonstrate the class in a program that creates a Car object, and then calls the accelerate method five times. After each call to the accelerate method, get the current speed of the car and display it. Then call the brake method five times. After each call to the brake method, get the current speed of the car and display it. 3. Personal Information Class Design a class that holds the following personal data: name, address, age, and phone num- ber. Write appropriate accessor and mutator methods. Demonstrate the class by writing a program that creates three instances of it. One instance should hold your information, and the other two should hold your friends' or family members' information

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

Database Driven Web Sites

Authors: Mike Morrison, Joline Morrison

1st Edition

061901556X, 978-0619015565

More Books

Students also viewed these Databases questions

Question

l Discuss the three major phases of a training system.

Answered: 1 week ago