Martes, Nobyembre 29, 2011

Write a Java application that calculate a payroll of an employee.Assumes that following must be indicated : Rate at Php108.33, Deduction: SSS=5.72% Pgibig=7.5% Philhealth=8.2% If No of hours work inputed is greaterthan 40 Overtime pay must be 15times of Rate per hours would be computed and if its less than 40 the program will be INVALID

import java.io.*;
public class payroll {
  
    public static void main(String[] args) throws IOException{
  BufferedReader num= new BufferedReader(new InputStreamReader(System.in));

     System.out.print("Enter Name: ");
    String name = num.readLine();
     System.out.print("No. of hours worked: ");
     int hw= Integer.parseInt(num.readLine());
     if(hw==40){
    double rate = 108.33;
    double net = rate*40;
     double sss = net*.0572;
     double ph= net*.082;
     double pi = net*.075;
     double tax= net*.12;
     double tded = sss+ph+pi+tax;
     double netpay = net-tded;
         System.out.println("Employee name: "+name);
         System.out.println("No of hours work: "+hw);
         System.out.println("Net Income: "+net);
         System.out.println("SSS: "+sss);
         System.out.println("ph: "+ph);
         System.out.println("pi: "+pi);
         System.out.println("tax: "+tax);
            System.out.println("Total Deduction: "+tded);
            System.out.println("Net Pay: "+netpay);

     }
 else if(hw > 40) {
        double othours = hw - 40;
        double otfee = (othours*1.5)*108.33;
        double rate = 108.33;
        double anet = rate*40;
        double net= anet+otfee;
        double sss = net*.0572;
     double ph= net*.082;
     double pi = net*.075;
     double tax= net*.12;
     double tded = sss+ph+pi+tax;
     double netpay =net-tded;
      System.out.println("Employee name: "+name);
         System.out.println("No of hours work: "+hw);
         System.out.println("Net Income: "+net);
         System.out.println("Overtime hours: "+othours);
         System.out.println("Overtime Fee's: "+otfee);
         System.out.println("Total Deduction: "+tded);
         System.out.println("Net Pay: "+netpay);

     }
 else if(hw < 40){
         System.out.println("Employee name: "+name);
         System.out.println("No of Hours Work: "+hw);
         System.out.println("Invalid hours ");
         
     }
    }

1 komento: