Answer to Question #273720 in Java | JSP | JSF for Dreaper

Question #273720

1.Write a Java program that calculates and prints the monthly pay for an employee. The net pay is calculated after taking the following deductions:

Witholding 15%

SSS contribution 3.63%

Medicare 1.25%

Pag-IBIG PHP 100.00

2.Initialize two (2) variables to hold the employee name and the gross pay (amount before deductions). See sample output below:

Employee Name: Jess Diaz

Gross Pay: 25000.0

Deductions Amount

Witholding Tax 3750.0

SSS Contributions: 907.5

Medicare: 312.5

Pagibig Contribution: 100.0

Net Pay: 19930.0



1
Expert's answer
2021-11-30T18:18:06-0500
package com.company;

import java.util.*;

public ​class Main
{
   ​public static void main(String[] args)
   ​{
      ​Scanner sc = new Scanner(System.in);
       ​System.out.print("Enter the number of Employees: ");
       ​int number_of_employees = sc.nextInt();
       ​if(number_of_employees == 0)
       ​{
           ​System.out.println("No employees given to our program");
       ​}
       ​else if(number_of_employees < 0)
       ​{
           ​System.out.println("Number of Employees cannot be negative");
       ​}
       ​else
       ​{
           ​//Declare an array to store the hours worked by every employee
           ​int [] hours_worked = new int[number_of_employees];
           ​int number_of_employee_count = 0;
           ​while(number_of_employee_count < number_of_employees)
           ​{
               ​System.out.print("Enter hours worked by Employee "+(number_of_employee_count+1)+": ");
               ​int hours = sc.nextInt();
               ​hours_worked[number_of_employee_count] = hours;
               ​number_of_employee_count = number_of_employee_count+1;
           ​}
           ​//Now lets calculate salary for the Employees
           ​System.out.println("");
           ​int stop_condition_count = 0;
           ​while(stop_condition_count < number_of_employees)
           ​{
               ​//check if the number of hours are more than 160
               ​if(hours_worked[stop_condition_count]>160)
               ​{
                   ​int monthly_salary = hours_worked[stop_condition_count]*320;
                   ​System.out.println("Monthly salary for Employee "+(stop_condition_count+1)+" = N$"+monthly_salary);
               ​}
               ​else
               ​{
                   ​int monthly_salary = hours_worked[stop_condition_count]*240;
                   ​System.out.println("Monthly salary for Employee "+(stop_condition_count+1)+" = N$"+monthly_salary);
               ​}
               ​stop_condition_count = stop_condition_count + 1;
           ​}
       ​}

   ​}

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