import java.util.*;
class salary
{
public static void main (String args[])
{
Scanner in = new Scanner (System.in);
double hpr,rh,oh;
System.out.print ("\n\t Enter hourly pay rate = ");
hpr=in.nextDouble();
System.out.print ("\n\t Enter regular hours = ");
rh=in.nextDouble();
System.out.print ("\n\t Enter overtime hours = ");
oh=in.nextDouble();
double rhp=0,otp,tp=0;
rhp = hpr*rh; //calculating regular hours pay: rhp
calculate ob = new calculate(); //creating object of class calculate
otp=ob.overtimepay(hpr,oh); //calling the method overtimepay
tp=rhp+otp; //calculating total pay
System.out.println ("\n\t Regular hours pay = "+rhp);
System.out.println ("\n\t Overtime pay = "+otp);
System.out.println ("\n\t Total pay = "+tp);
}
}
class calculate
{
double otp;
double overtimepay (double hpr, double oh) //recieving hourly pay rate and overtime hours hpr, oh respectively
{
otp=(hpr*0.5)*oh; //calculating overtime pay
return otp;
}
}
class salary
{
public static void main (String args[])
{
Scanner in = new Scanner (System.in);
double hpr,rh,oh;
System.out.print ("\n\t Enter hourly pay rate = ");
hpr=in.nextDouble();
System.out.print ("\n\t Enter regular hours = ");
rh=in.nextDouble();
System.out.print ("\n\t Enter overtime hours = ");
oh=in.nextDouble();
double rhp=0,otp,tp=0;
rhp = hpr*rh; //calculating regular hours pay: rhp
calculate ob = new calculate(); //creating object of class calculate
otp=ob.overtimepay(hpr,oh); //calling the method overtimepay
tp=rhp+otp; //calculating total pay
System.out.println ("\n\t Regular hours pay = "+rhp);
System.out.println ("\n\t Overtime pay = "+otp);
System.out.println ("\n\t Total pay = "+tp);
}
}
class calculate
{
double otp;
double overtimepay (double hpr, double oh) //recieving hourly pay rate and overtime hours hpr, oh respectively
{
otp=(hpr*0.5)*oh; //calculating overtime pay
return otp;
}
}
hello....i need the solution for= A worker normally works 40 hours a week. Excess overtime hours are paid 1.5 times the
ReplyDeletehourly rate, if the overtime hours are less than 10, 2 times if 10 to 20 hours inclusive, and 3
times if over 20 hours.
Write a program that asks the user to input number of hours worked for a week and hourly
pay. Then calculate his salary.