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:
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:
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images