Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please Use Netbeans Create four pages: Three Classes: Employee, Department, and Company A program MyCompany which supplies employee name and salary information and prints out

Please Use Netbeans

Create four pages: Three Classes: Employee, Department, and Company A program MyCompany which supplies employee name and salary information and prints out the total salary of all the employees. Pass in all four .java files. 1) Create a class called "Employee" with the following properties: name (String) age (int) salary (double) In the Employee class, create a constructor that accepts and sets an employees name, age, and salary. Create getters for name, age, and salary. 2) Create a class called "Department" with the following properties: i (int) name (String) Employee[] employees=new Employee[10]; In the Department class, create a constructor that accepts and sets the department name. Also set i=0 (to initialize the value). In the Department class create a method called "addEmployee" that accepts an Employee object and adds it to the array of employees. (Hint, include i++ to increment the value of i.) In the Department class, create a method called "getTotalSalary" as follows: public double getTotalSalary() {

double total = 0; for (int z=0;z

4) Create a program MyCompany as given below:

public class MyCompany { public static void main(String[] args) { Employee e1 = new Employee("John", 25, 5000); Employee e2 = new Employee("Jane", 30, 6000); Employee e3 = new Employee("Jim", 35, 7000); Employee e4 = new Employee("Jack", 40, 8000); Employee e5 = new Employee("Jill", 45, 9000); Department d1 = new Department("Sales"); d1.addEmployee(e1); d1.addEmployee(e2); Department d2 = new Department("Marketing"); d2.addEmployee(e3); d2.addEmployee(e4); Department d3 = new Department("IT"); d3.addEmployee(e5); Company c = new Company("ACME Inc."); c.addDepartment(d1); c.addDepartment(d2); c.addDepartment(d3); System.out.println("Total salary of all employees: " + c.getTotalSalary()); }

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

More Books

Students also viewed these Databases questions

Question

2. What potential barriers would you encourage Samuel to avoid?

Answered: 1 week ago