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:

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
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
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Array
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
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education