USING IF ELSE CONDITIONAL STATEMENT
Write a JAVA program that will input Employee Name, Rate per hour, No. of hours worked
and will compute the daily wage of an employee. If the number of hours worked exceeds
eight hours add 30% to each excess hour as overtime rate.
Formula: Daily Wage = Rate per hour * No. of hours worked + OT pay
package dailywage;
import java.util.Scanner;
public class DailyWage {
public static void main(String[] args) {
System.out.println("Enter the Employee Name: \n");
Scanner scan = new Scanner(System.in);
String EmployeeName = scan.nextLine();
System.out.println("Enter the Rate per hour: \n");
double rate = scan.nextDouble();
System.out.println("Enter the No. of hours worked: \n");
double hours = scan.nextDouble();
double daily_wage = 0;
if(hours > 8){
daily_wage = rate * hours + (hours - 8) * 0.3;
}
else{
daily_wage = rate * hours;
}
System.out.println("Total Tuition Fee is: \n"+daily_wage);
}
}
Comments
Leave a comment