Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Java 1. Define a class Employee with following members: Data Members: Modifier.

ID: 3907740 • Letter: J

Question

Java
1. Define a class Employee with following members:   


Data Members:
Modifier. Description. Data Type. Name
Private. Employee number. Integer. Eno
Private Employee Name. String. Ename
Private. Number of.   Array double[7] Hours[7] hours worked for each day

Private. Salary for each day. Arraydouble[7]. Salary[7]
Private. Per hour salary. double. Rate
Private. Gross Salary. double. Gross_Salary

Methods
Modifier. Name. Description
Employee(). Constructor to assign values to blanks or 0
Public. Input(). Method to take the input of Eno, Ename, Hours [7], Rate and call Calculate()
Public. Display(). To display the contents of all fields
Public. Calculate(). Calculates the salary for each day as per the table below, and then calculates Gross_Salary

The Salary for each day is calculated as per the following criteria:
First 8 hours are paid as per the hourly rate. Next 4 hours are paid at the rate of 1.5*rate Remaining hours are paid at the rate of 2*rate Weekends are paid at the rate of 2*rate
The Input method should verify that the number of hours have a valid input for each day (>=0 and <=24). Use appropriate code for the same.

The program should create an object of Employee and call the methods for doing the operations. The field values should be displayed in the end. Java
1. Define a class Employee with following members:   


Data Members:
Modifier. Description. Data Type. Name
Private. Employee number. Integer. Eno
Private Employee Name. String. Ename
Private. Number of.   Array double[7] Hours[7] hours worked for each day

Private. Salary for each day. Arraydouble[7]. Salary[7]
Private. Per hour salary. double. Rate
Private. Gross Salary. double. Gross_Salary

Methods
Modifier. Name. Description
Employee(). Constructor to assign values to blanks or 0
Public. Input(). Method to take the input of Eno, Ename, Hours [7], Rate and call Calculate()
Public. Display(). To display the contents of all fields
Public. Calculate(). Calculates the salary for each day as per the table below, and then calculates Gross_Salary

The Salary for each day is calculated as per the following criteria:
First 8 hours are paid as per the hourly rate. Next 4 hours are paid at the rate of 1.5*rate Remaining hours are paid at the rate of 2*rate Weekends are paid at the rate of 2*rate
The Input method should verify that the number of hours have a valid input for each day (>=0 and <=24). Use appropriate code for the same.

The program should create an object of Employee and call the methods for doing the operations. The field values should be displayed in the end.
1. Define a class Employee with following members:   


Data Members:
Modifier. Description. Data Type. Name
Private. Employee number. Integer. Eno
Private Employee Name. String. Ename
Private. Number of.   Array double[7] Hours[7] hours worked for each day

Private. Salary for each day. Arraydouble[7]. Salary[7]
Private. Per hour salary. double. Rate
Private. Gross Salary. double. Gross_Salary

Methods
Modifier. Name. Description
Employee(). Constructor to assign values to blanks or 0
Public. Input(). Method to take the input of Eno, Ename, Hours [7], Rate and call Calculate()
Public. Display(). To display the contents of all fields
Public. Calculate(). Calculates the salary for each day as per the table below, and then calculates Gross_Salary

The Salary for each day is calculated as per the following criteria:
First 8 hours are paid as per the hourly rate. Next 4 hours are paid at the rate of 1.5*rate Remaining hours are paid at the rate of 2*rate Weekends are paid at the rate of 2*rate
The Input method should verify that the number of hours have a valid input for each day (>=0 and <=24). Use appropriate code for the same.

The program should create an object of Employee and call the methods for doing the operations. The field values should be displayed in the end. 1. Define a class Employee with following members:   


Data Members:
Modifier. Description. Data Type. Name
Private. Employee number. Integer. Eno
Private Employee Name. String. Ename
Private. Number of.   Array double[7] Hours[7] hours worked for each day

Private. Salary for each day. Arraydouble[7]. Salary[7]
Private. Per hour salary. double. Rate
Private. Gross Salary. double. Gross_Salary

Methods
Modifier. Name. Description
Employee(). Constructor to assign values to blanks or 0
Public. Input(). Method to take the input of Eno, Ename, Hours [7], Rate and call Calculate()
Public. Display(). To display the contents of all fields
Public. Calculate(). Calculates the salary for each day as per the table below, and then calculates Gross_Salary

The Salary for each day is calculated as per the following criteria:
First 8 hours are paid as per the hourly rate. Next 4 hours are paid at the rate of 1.5*rate Remaining hours are paid at the rate of 2*rate Weekends are paid at the rate of 2*rate
The Input method should verify that the number of hours have a valid input for each day (>=0 and <=24). Use appropriate code for the same.

The program should create an object of Employee and call the methods for doing the operations. The field values should be displayed in the end.

Explanation / Answer

import java.io.*;
import java.util.*;

class Employee {

   private String ename;
   private int eno;
   private double[] hours;
   private double[] salary;
   private double rate;
   private double gross_salary;

   public Employee(){
          ename = "";
          eno = 0;
          hours = new double[7];
          for (int i = 0; i<7; i++)
              hours[i] = 0;
          salary = new double[7];
          for (int i = 0; i<7; i++)
              hours[i] = 0;
          rate = 0;
          gross_salary = 0;
   }
   void Input(){
        Scanner sc = new Scanner(System.in);
        System.out.println("Enter eno:");
        eno = Integer.parseInt(sc.nextLine());
        System.out.println("Enter ename:");
        ename = sc.nextLine();
        System.out.println("Enter hours for 7 days separated with spaces:");
        String line = sc.nextLine();
        String[] list = line.split(" ");
        for (int i = 0; i<7; i++){
            hours[i] = Double.parseDouble(list[i]);
        }
        Calculate();
              
   }
   void Calculate(){

       gross_salary = 0.0;
       for (int i = 0; i<7; i++){
           if (i < 5){
              double a = hours[i];
              if (a >= 8){
                 salary[i] = 8 * rate;
              }
              a = a - 8;
              if (a >= 4){
                 salary[i] = salary[i] + 4 * 1.5 * rate;
              }
              a = a - 4;
              if (a > 0){
                 salary[i] = salary[i] + a * 2 * rate;
              }
              gross_salary = gross_salary + salary[i];
           }
           else {
              salary[i] = hours[i] * 2 * rate;
              gross_salary = gross_salary + salary[i];
           }
       }
   }
   void Display(){

        System.out.println("eno:" + eno);
        System.out.println("ename:" + ename);
        System.out.println("Hours worked:");
        for (int i = 0; i<7; i++){
           System.out.print(hours[i]+ " ");
        }
        System.out.println("Salaries:");
        for (int i = 0; i<7; i++){
           System.out.print(salary[i]+ " ");
        }
        System.out.println("Gross Salary:" + gross_salary);
            
   }   
}

public class Demo196{
      public static void main(String[] args){
           Employee e = new Employee();
           e.Input();
           e.Display();
      }
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote