Question :
An employee gets paid (hours worked) × (basic pay), for each hour up
to 40 hours.
For every hour over 40, they get overtime = (basic pay) × 1.5. The
basic pay must not be less than the minimum wage ($8.00 an hour).
If it is, print an error.
If the number of hours is greater than 60, he is paid for 60 hours
Write a JAVA code to calculate for each of these employees:
Basic Pay Hours Worked
Employee 1 $7.50 35
Employee 2 $8.20 47
Employee 3 $10.00 73
Employee 4 $7.00 65.
Answer :
class Sal
{
double salary(double b,int h)
{
int i,j=0;
if(h<40)
{
j=h;
}
else if(h>40&&h<60)
{
i=h%40;
j=40;
}
else
{
i=20;
j=40;
}
double d=(j*b)+(i*1.5*b);
return d;
}
public static void main(String args[])
{
System.out.println("Enter the no. of emplyees for who you want to
calculate the salary");
int i=System.in.read();
for(int r=0;r<i;r++)
{
System.out.println("Enter the Basic Pay.");
double basic_pay=System.in.read();
if(basic_pay<8.0)
{
System.out.println("Basic Pay cannot be less than $8.00");
goto l;
}
System.out.println("Enter the no. of hours worked");
int hour=System.in.read();
double total_salary=salary(basic_pay,hour);
System.out.println("Total Salary of "+r+"th person is "+total_salary);
l:
}
}
}
Note : This program can be used to find the salaries of as many
persons according to the specified rules.
Subscribe to:
Post Comments (Atom)
Mentor List
,Year,Roll No,Regn No,Student Name,Mentor/faculty,Mentor Ph No,Mentor e Mail 1,4th yr BTech,417001,2201105001,ABHILASH DEHURY,Prof S.N.Mishr...
-
Cloud Computing Note https://drive.google.com/file/d/1LasotF7wO8zu5Cocr-czxJ_zo5GV_VaL/view?usp=drive_link Cloud Computing...
-
Cloud Computing Note https://drive.google.com/file/d/1LasotF7wO8zu5Cocr-czxJ_zo5GV_VaL/view?usp=drive_link Cloud Computing...
-
,Year,Roll No,Regn No,Student Name,Mentor/faculty,Mentor Ph No,Mentor e Mail 1,4th yr BTech,417001,2201105001,ABHILASH DEHURY,Prof S.N.Mishr...
No comments:
Post a Comment