Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

bartleby

Concept explainers

Question

Suppose you are given a `Employee` class with instance variables `name`, `age`,

 

`department, and salary. You are also given a static variable "total Employees and a static variable `totalSalary`, which respectively keep track of the total number of employees and the total salary of all employees.

 

Using this class, write a Java program that does the following:

 

1. Create an array of size 3 to store Employee objects.

 

2. Initialize the array with the following Employee` objects:

 

• Name: Alice, Age: 25, Department: HR, Salary: 50,000

 

Name: Bob, Age: 35, Department: Marketing, Salary: 60,000

 

Name: Charlie, Age: 30, Department: Sales, Salary: 55,000

 

3. Modify the age of the first employee in the array to 26.

 

4. Modify the salary of the second employee in the array to 65,000.

 

5. Print out the total number of employees and the average salary of all employees.

 

6. Use the static method `findEmployeeByName to find the `Employee` object with the name "Alice", and print out the `toString()` representation of this object.

 

7. Use the instance method `isolderThan` to determine if the first employee in the array is older than 30. Print out the result of this determination.

 

8. Use the instance method `promote` to give a raise of 10,000 to the first employee in

 

the array, and print out the new salary of this employee.

 

Your program should output the following:

 

csharp

 

Copy code

 

Total number of employees: 31

 

Average salary: 55000.0

 

Employee

 

found by

 

Employee 1 is

 

Employee [name='Alice',

 

age=26,

 

department='HR',

 

sala

 

Employee 

 

older than

 

30: false

 

60000.0

 

salary:

 

1 new

 

name:

Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education