Thursday, 30 August 2012

NAME- DEBAPRAKASH KALANDI, ROLL NO.-29711/1001105069, ASSIGNMENT CODE- CSEL-10X

/*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 Salary
{
public static void main(String[] args)
{
double basic[]={7.50,8.20,10.00,7.00};
int hr[]={35,47,73,65};
double sal[]={0.00,0.00,0.00,0.00};

for(int i=0;i<4;i++)
{
if(basic[i]<8.00)

{
System.out.println("\n ERROR, The basic pay
must not be less than the minimum wage ($8.00 an hour)");
}

else if(hr[i]>40&&hr[i]<=60)
{
int overtime=hr[i]-40;
total[i]=(basic[i]*40)+(overtime*basic[i]*1.5);
System.out.println(("Total Salary= "+total[i]+"$");
}

else if(hr[i]>60)
{
total[i]=(basic[i]*40)+(20*basic[i]*1.5);
System.out.println("Total Salary= "+total[i]+"$");
}
}
}

No comments:

Post a Comment

C Programming

  Table of Contents ​ About the Author 3 ​ Introduction 4 ​ Introduction to Computers 4 1. What is a Computer? 4 2. History...