SOURCE CODE:
import java.util.Scanner;
public class PayrollProgram {
public static void main(String[] args) {
Scanner xray = new Scanner(System.in);
setEmpInfo re = new setEmpInfo ("", 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0.0, 0.0);
while(true){
System.out.println("Enter employee's name or stop to quit: ");
re.name = xray.nextLine();
if(re.name.toLowerCase().equals("stop")){
System.exit(0);
}
System.out.println("\nNo. of Days Worked: ");
re.days = xray.nextDouble();
if(re.days <= 0){
System.out.println("Enter No. of Days Worked again: ");
re.days = xray.nextDouble();
}
System.out.println("Rate per Day: ");
re.rpd = xray.nextDouble();
if(re.rpd <= 0){
System.out.println("Enter Rate per Day again: ");
re.rpd = xray.nextDouble();
}
System.out.printf("\n");
re.gross = re.days * re.rpd;
System.out.printf("Employee's Name: %s", re.name);
System.out.println("\nGross Salary");
System.out.printf("Php %.2f\n\n", re.gross);
re.lifeandretirementps = re.rpd * 22 * 0.09;
System.out.println("Life and Retirement (Personal Share)");
System.out.printf("Php %.2f\n", re.lifeandretirementps);
re.lifeandretirementgs = re.rpd * 22 * 0.12;
System.out.println("Life and Retirement (Government Share)");
System.out.printf("Php %.2f\n\n", re.lifeandretirementgs);
re.pagibigps = re.rpd * 22 * 0.02;
System.out.println("PAG-IBIG (Personal Share)");
System.out.printf("Php %.2f\n", re.pagibigps);
re.pagibiggs = re.rpd * 22 * 0.02;
System.out.println("PAG-IBIG (Goverment share)");
System.out.printf("Php %.2f\n\n", re.pagibiggs);
re.stateinsurance = re.rpd * 22 * 0.01;
if(re.stateinsurance >= 100.00){
System.out.println("State Insurance");
System.out.printf("Php 100.00\n\n", re.stateinsurance);
}
else if(re.stateinsurance >= 90.00 && re.stateinsurance <= 99.99){
System.out.println("State Insurance");
System.out.printf("Php %.2f\n\n", re.stateinsurance);
}
re.stateinsurance = re.rpd * 22 * 0.01;
if(re.stateinsurance >= 100.00){
re.salarybracket = 125.00;
re.philhealthps = re.salarybracket;
System.out.println("PHILHEALTH (Personal share)");
System.out.printf("Php %.2f\n", re.philhealthps);
re.philhealthgs = re.salarybracket;
System.out.println("PHILHEALTH (Goverment share)");
System.out.printf("Php %.2f\n\n", re.philhealthgs);
}
else if(re.stateinsurance >= 90.00 || re.stateinsurance <= 99.99){
re.salarybracket = 112.50;
re.philhealthps = re.salarybracket;
System.out.println("PHILHEALTH (Personal share)");
System.out.printf("Php %.2f\n", re.philhealthps);
re.philhealthgs = re.salarybracket;
System.out.println("PHILHEALTH (Goverment share)");
System.out.printf("Php %.2f\n\n", re.philhealthgs);
}
re.montuary = 100.00;
System.out.println("Montuary");
System.out.printf("Php %.2f\n\n", re.montuary);
re.totaldeduction = re.lifeandretirementps + re.pagibigps + re.philhealthps + re.montuary;
System.out.println("Total Deduction");
System.out.printf("Php %.2f\n\n", re.totaldeduction);
re.nettakehomepay = re.gross - re.totaldeduction;
System.out.println("Net Take Home Pay");
System.out.printf("Php %.2f\n\n", re.nettakehomepay);
xray.nextLine();
}
}
}
class setEmpInfo extends PayrollProgram{
String name;
double days;
double rpd;
double gross;
double lifeandretirementps;
double lifeandretirementgs;
double pagibigps;
double pagibiggs;
double philhealthps;
double philhealthgs;
double stateinsurance;
double salarybracket;
double montuary;
double totaldeduction;
double nettakehomepay;
setEmpInfo(String xname,
double xdays,
double xrpd,
double xgross,
double xliferetirementps,
double xliferetirementgs,
double xpagibigps,
double xpagibiggs,
double xphilhealthps,
double xphilhealthgs,
double xstateinsurance,
double xsalarybracket,
double xmontuary,
double xtotaldeduction,
double xnettakehomepay) {
name = xname;
days = xdays;
rpd = xrpd;
gross = xgross;
lifeandretirementps = xliferetirementps;
lifeandretirementgs = xliferetirementgs;
pagibigps = xpagibigps;
pagibigps = xpagibiggs;
philhealthps = xphilhealthps;
philhealthps = xphilhealthgs;
stateinsurance = xstateinsurance;
salarybracket = xsalarybracket;
montuary = xmontuary;
totaldeduction = xtotaldeduction;
nettakehomepay = xnettakehomepay;
}
public double calc(){
return days * rpd;
}
OUTPUT:
Enter employee's name or stop to quit:
Mike Tyson
No. of Days Worked:
10
Rate per Day:
449.13
Employee's Name: Mike Tyson
Gross Salary
Php 4491.30
Life and Retirement (Personal Share)
Php 889.28
Life and Retirement (Government Share)
Php 1185.70
PAG-IBIG (Personal Share)
Php 197.62
PAG-IBIG (Goverment share)
Php 197.62
State Insurance
Php 98.81
PHILHEALTH (Personal share)
Php 112.50
PHILHEALTH (Goverment share)
Php 112.50
Montuary
Php 100.00
Total Deduction
Php 1299.39
Net Take Home Pay
Php 3191.91
MY PROBLEM:
re.totaldeduction(1299.39) = re.lifeandretirementps(889.28) + re.pagibigps(197.62) + rephilhealthps(112.50) + re.montuary(100.00)
Suppose to be the answer for Total Reduction is 1299.40 not 1299.39
and Net Take Home Pay is 3191.90 not 3191.91. Please HELP ME JAVA MASTERS!!!