Machine Problem in Java
Payroll that includes five double field variables that hold hours
worked, rate of pay per hour, withholding rate, gross pay, and net pay, and three String
field variables that holds the last name, first name and position of the employee.
Create three overloaded computeNetPay() methods.
When computeNetPay() receives values
for hours, pay rate, and withholding rate, it computes the gross pay and reduces it by
the appropriate withholding amount to produce the net pay.
When computeNetPay()
receives two arguments, they represent the hours and pay rate, and the withholding
rate is assumed to be 10%.
When computeNetPay() receives one argument, it
represents the number of hours worked, the withholding rate is assumed to be 10%,
and the hourly rate is assumed to be 59.65.
Name the program as Payroll.java
The gross pay is computed as hours worked multiplied by pay per hour.
Display the last name, first name, position, total pay for the hour's work, withholding
rate, gross pay and the net pay of the employee.
I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details. If you want to advertise on my website kindly contact me also in my email address also. Thank you.
My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.
My mobile number here in the Philippines is 09173084360.
My telephone number at home here in Bacolod City, Negros Occidental Philippines is +63 (034) 4335675.
Here in Bacolod City I also accepting computer repair, networking, and Arduino Project development at a very affordable price. My website is www.jakerpomperada.blogspot.com and www.jakerpomperada.com
If you like this video please click the LIKE button, SHARE, and SUBSCRIBE to my channel.
Your support on my channel is highly appreciated.
Thank you very much.
Program Listing
Payroll.java
// Payroll.java
// Author : Mr. Jake Rodriguez Pomperada, MAED-IT, MIT
// www.jakerpomperada.com , www.jakerpomperada.blogspot.com
// jakerpomperada@gmail.com
// Bacolod City, Negros Occidental,Philippines
// December 3, 2020 Thursday
import java.text.DecimalFormat;
public class Payroll {
private static DecimalFormat df2 = new DecimalFormat("#.##");
public void EmployeesRecord(String LastName, String FirstName, String Position )
{
System.out.println("\n");
System.out.println("\tEMPLOYEE'S INFORMATION");
System.out.println();
System.out.println("\tEmployee's LastName : " + LastName );
System.out.println("\tEmployee's FirstName : " + FirstName );
System.out.println("\tEmployee's Postion : " + Position );
System.out.println();
}
// Method Overloading computeNetPay() No. 1
public void computeNetPay(double hoursWork, double pay_rate,double withholding_rate)
{
double gross_pay=0.00;
double solve_netpay=0.00;
double tax=0.00;
double solve_percentage=0.00;
solve_percentage = (withholding_rate/100);
gross_pay = (hoursWork* pay_rate);
tax = (gross_pay * solve_percentage);
solve_netpay = (gross_pay - tax);
System.out.println("\tThe Net Pay is PHP "+ df2.format(solve_netpay));
}
// Method Overloading computeNetPay() No. 2
public void computeNetPay(double hoursWork, double pay_rate)
{
double gross_pay;
double solve_netpay;
double tax;
double withholding_rate = 0.10;
gross_pay = (hoursWork* pay_rate);
tax = (gross_pay * withholding_rate);
solve_netpay = (gross_pay - tax);
System.out.println("\tThe Net Pay PHP "+ df2.format(solve_netpay));
}
// Method Overloading computeNetPay() No. 3
public void computeNetPay(double hoursWork)
{
double gross_pay;
double solve_netpay;
double tax;
double pay_rate = 59.65;
double withholding_rate = 0.10;
gross_pay = (hoursWork* pay_rate);
tax = (gross_pay * withholding_rate);
solve_netpay = (gross_pay - tax);
System.out.println("\tThe Net Pay PHP "+ df2.format(solve_netpay));
}
public static void main(String[] args) {
// TODO Auto-generated method stub
Payroll employee1=new Payroll();
Payroll employee2=new Payroll();
Payroll employee3=new Payroll();
System.out.println("\n");
System.out.print("\tPayroll Program in Java Using Method Overloading");
// Method Overloading computeNetPay() No. 1
employee1.EmployeesRecord("Pomperada","Jake", "Jave Developer");
employee1.computeNetPay(15,250.60,12);
// Method Overloading computeNetPay() No. 2
employee2.EmployeesRecord("Pomperada","Allie", "Chemical Engineer");
employee2.computeNetPay(40,485.71);
// Method Overloading computeNetPay() No. 3
employee3.EmployeesRecord("Pomperada","Jacob Samuel", "Software Architect");
employee3.computeNetPay(35);
System.out.println("\n");
System.out.print("\tEnd of Program");
System.out.println("\n");
}
}