Following are three arrays each containing 20 data Array emp

Following are three arrays, each containing 20 data. Array emp_hours contain the number of hours worked by 20 employees. Array emy_hourly_pay contain the hourly pay for the same 20 employees. Array emp_dependents contain the number of dependents for each of the same 20 employees.

double []emp_hours = {45, 40, 40, 42, 35, 40, 40, 50, 45, 35, 40, 40, 40, 30, 40, 40, 50, 45, 40, 40};

double []emp_hourly_pay = {15, 50, 32, 18, 20, 60, 25, 20, 30, 100, 20, 35, 30, 20, 50, 45, 25, 30, 55, 20};

double []emp_dependents = {0, 0, 5, 2, 7, 2, 2, 1, 0, 0, 3, 2, 4, 4, 5, 0, 1, 1, 2, 4};

Number of dependents

Taxable income (Gross pay gets reduced by following percentages)

0

0%

1

4%

2

7.75%

3

11.25%

4

14.5%

5

17.5%

6 and above

20.25%

Taxable Income

Tax Rate

0-500

10%

501-1000

15%

1001-1500

25%

1501-2000

40%

Above 2000

50%

1: Print the gross_income for all 20 employees.

2: Print the taxble income for all 20 employees.

3: Print the taxes for all 20 employees.

4: Print the net pay for all 20 employees.

Note: create an array for gross_pay, taxable_income, taxes, and net pay.

Example: double gross_pay = new double[20];

Number of dependents

Taxable income (Gross pay gets reduced by following percentages)

0

0%

1

4%

2

7.75%

3

11.25%

4

14.5%

5

17.5%

6 and above

20.25%

Solution

import java.util.*;
public class Employee
{
public static void main (String[] args)
{
       double gross_income;
       double gross_pay[] = new double[20];
       double tax;
       double Taxableincome;
       double taxable_income[] = new double[20];
       double taxes[] = new double[20];
      
       double []emp_hours = {45, 40, 40, 42, 35, 40, 40, 50, 45, 35, 40, 40, 40, 30, 40, 40, 50, 45, 40, 40};
       double []emp_hourly_pay = {15, 50, 32, 18, 20, 60, 25, 20, 30, 100, 20, 35, 30, 20, 50, 45, 25, 30, 55, 20};
       double []emp_dependents = {0, 0, 5, 2, 7, 2, 2, 1, 0, 0, 3, 2, 4, 4, 5, 0, 1, 1, 2, 4};
       //Scanner scan = new Scanner(System.in);// creating scan object from Scanner class
       //System.out.println(\"\ 1:Print the gross_income for all 20 employees.\ 2: Print the taxble income for all 20 employees.\ 3: Print the taxes for all 20 employees.\ 4: Print the net pay for all 20 employees.\");
       //int option=scan.nextInt(); // declaring amount variable and taking input from user
          
       for(int i=0;i<20;i++){
           gross_income = emp_hours[i]*emp_hourly_pay[i];
           gross_pay[i]=gross_income;
           System.out.println(\"Gross_income for Employee \"+(i+1)+\" \"+gross_income);          
           }
       for(int i=0;i<20;i++){
           if(emp_dependents[i]==0){              
           Taxableincome=gross_pay[i];
           taxable_income[i]=Taxableincome;      
           }else if(emp_dependents[i]==1){
               double reduce=(gross_pay[i]*4)/100;
               Taxableincome=gross_pay[i]-reduce;
               taxable_income[i]=Taxableincome;      
           }else if(emp_dependents[i]==2){
                   double reduce=(gross_pay[i]*7.75)/100;
                   Taxableincome=gross_pay[i]-reduce;
                   taxable_income[i]=Taxableincome;      
           }else if(emp_dependents[i]==3){
                   double reduce=(gross_pay[i]*11.25)/100;
                   Taxableincome=gross_pay[i]-reduce;
                   taxable_income[i]=Taxableincome;      
                   }
           else if(emp_dependents[i]==4){
                   double reduce=(gross_pay[i]*14.5)/100;
                   Taxableincome=gross_pay[i]-reduce;
                   taxable_income[i]=Taxableincome;      
                   }
           else if(emp_dependents[i]==5){
                   double reduce=(gross_pay[i]*17.5)/100;
                   Taxableincome=gross_pay[i]-reduce;
                   taxable_income[i]=Taxableincome;      
           }else if(emp_dependents[i]>=6){
                   double reduce=(gross_pay[i]*20.25)/100;
                   Taxableincome=gross_pay[i]-reduce;
                   taxable_income[i]=Taxableincome;      
                   }  
       }
       System.out.println(\"Taxable incomes for all Employess:\");
       for(int i=0;i<20;i++){
           System.out.println(\"Taxable incomes for Employee \"+(i+1)+\" \"+taxable_income[i]);
           }
       for(int i=0;i<20;i++){
           if(taxable_income[i]>=0 && taxable_income[i]<=500){
               tax=(taxable_income[i]*10)/100;
               taxes[i]=tax;
           }else if(taxable_income[i]>=501 && taxable_income[i]<=1000){
               tax=(taxable_income[i]*15)/100;
               taxes[i]=tax;
           }else if(taxable_income[i]>=1001 && taxable_income[i]<=1500){
               tax=(taxable_income[i]*25)/100;
               taxes[i]=tax;
           }
           else if(taxable_income[i]>=1501 && taxable_income[i]<=2000){
               tax=(taxable_income[i]*40)/100;
               taxes[i]=tax;
           }else if(taxable_income[i]>2000){
               tax=(taxable_income[i]*50)/100;
               taxes[i]=tax;
           }  
       }
       System.out.println(\"Taxes for All Employees\");
       for (int i=0; i<20;i++){
           System.out.println(\"Taxes for Employee \"+(i+1)+\" :\"+taxes[i]);
          
       }
       System.out.println(\"Net pay for all 20 employees\");
       for (int i=0; i<20;i++){
           System.out.println(\"Net pay \"+(i+1)+\" :\"+(gross_pay[i]-taxes[i]));
          
       }
      
   }
}

Following are three arrays, each containing 20 data. Array emp_hours contain the number of hours worked by 20 employees. Array emy_hourly_pay contain the hourly
Following are three arrays, each containing 20 data. Array emp_hours contain the number of hours worked by 20 employees. Array emy_hourly_pay contain the hourly
Following are three arrays, each containing 20 data. Array emp_hours contain the number of hours worked by 20 employees. Array emy_hourly_pay contain the hourly

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site