Write a program that will input the category of an employee C- Contractual P – Probationary R –Regular, if the user input is none among the c, p, r displays invalid input. Input the number of days worked, display the employee rate, if contractual daily rate is 350, if probationary daily rate is 400, if regular daily rate is 450. Then compute and display the basic pay.

PHOTO EMBED

Sun Dec 08 2024 10:35:25 GMT+0000 (Coordinated Universal Time)

Saved by @John_Almer

package employeessalary;
import java.util.Scanner;
public class EmployeesSalary {

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

        System.out.print("Enter the employee category (c/p/r): ");
        char category = input.next().charAt(0);

        System.out.print("Enter number of days worked: ");
        int daysWorked = input.nextInt();

        double dailyRate;
        String categoryName;

        switch (category) {
            case 'c':
                dailyRate = 350;
                categoryName = "Contractual";
                break;
            case 'p':
                dailyRate = 400;
                categoryName = "Probationary";
                break;
            case 'r':
                dailyRate = 450;
                categoryName = "Regular";
                break;
            default:
                dailyRate = 0;
                categoryName = "Invalid Input";
        }

        double basicPay = dailyRate * daysWorked;

        System.out.println("Category: " + categoryName);
        System.out.println("Daily Rate: " + dailyRate);
        System.out.println("Basic Pay: " + basicPay);
    }
}
content_copyCOPY