Question #322993

Q: Write a program that displays the following menu to the user:

Press 1 for Permanent Employee

Press 2 for Daily wages Employee

After selecting the appropriate employee calculate salary for the employees.

The daily wages employees are paid 400 per hour while permanent employees are paid 800 per hour. First you need to ask for the number of hours for which the employee has worked so far and then calculate and display the salary of each type of employee.

Perform the above-mentioned task using switch statement. 


Expert's answer

import java.util.Scanner;

public class MyMainClass {

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


        System.out.print(   "Press 1 for Permanent Employee\n" +
                            "Press 2 for Daily wages Employee\n" +
                            "Enter: ");
        int v = in.nextInt();

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

        switch(v){
            case 1:
                System.out.print("Employee salary = " + (ho*800));
                break;
            case 2:
                System.out.print("Employee salary = " + (ho*400));
                break;
        }


    }
}
LATEST TUTORIALS
APPROVED BY CLIENTS