Answer to Question #240102 in Java | JSP | JSF for Dylan Cupido

Question #240102

Required:

1. Code the classes Employee, Manager and Secretary.

2. Code an application with a main method. In this class you must code an array of type Employee with a maximum size of 20.

a. Add a minimum of 10 objects to the array. You may hard-code these object values. The objects must be a mixture of Employee, Manager and Secretary.

b. Display all the objects on the screen.

c. Calculate, and then display, the average salary of all employees.

Extra

Calculate and display the cost of the leave to the company for each employee.


1
Expert's answer
2021-09-22T00:00:30-0400
import java.util.Scanner;
class Employee {
    public Employee() {
        System.out.println("Employee!");
    }
    
    public Employee(String name) {
        System.out.println(name);
    }
}


class Manager{
    public Manager() {
        System.out.println("Manager!");
    }
    
    public Manager(String name) {
        System.out.println(name);
    }
}
class Secretary{
    public Secretary() {
        System.out.println("Secretary!");
    }
    
    public Secretary(String name) {
        System.out.println(name);
    }
}


public class Main {




    public static void main(String[] args) {
        int sum=0;
        Scanner input=new Scanner(System.in);
        
        System.out.print("Enter the average  salary of the employees: ");
        for(int i=0;i<20;i++){
           
            sum += input.nextInt();}
            double average=sum/20;
            System.out.println("Average salary of the employees is: ");
            System.out.println(average);
            int leave=3000;
            System.out.println("Cost of leave for each employee is: ");
            System.out.println(leave);
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS