An employee is paid P50.00 per hour for the first 40 hours of his service. If he works more than 40 hours, he gets P30.00 for each extra hour. Input the number of hours an employee worked during the week and output his salary.

PHOTO EMBED

Sun Dec 08 2024 10:16:07 GMT+0000 (Coordinated Universal Time)

Saved by @John_Almer

package employeesalary;
import java.util.Scanner;
public class EmployeeSalary {

   
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);

        System.out.print("Enter the number of hours worked: ");
        int hoursWorked = input.nextInt();

        double salary = 0;
        if (hoursWorked <= 40) {
            salary = hoursWorked * 50;
        } else {
            salary = 40 * 50 + (hoursWorked - 40) * 30;
        }

        System.out.println("The salary is: " + salary);
    }
}
  
content_copyCOPY