Question #20407

Write a program that calculates the salary for the employee. The hourly rate for permanent staff (P) is 200, contract staff (C) is 150 and temporary staff (T) is 100. The program accepts the employee type and the number of hours the employee work.

Expert's answer

import java.util.Scanner;

public class Salary {

public static void main (String... args) {

Scanner scanner = newScanner(System.in);

System.out.print("
Enteremployee type (permanent(P) contract(C) temporary(T):");
char staffType = scanner.nextLine().toLowerCase().charAt(0);
int hourlyRate=0;
switch (staffType) {
case 'p' :hourlyRate=200; break;
case 'c' :hourlyRate=150; break;
case 't' :hourlyRate=100; break;
default:System.exit(0);
}
System.out.print("
Enternumber of hours the employee work :");
int hours = scanner.nextInt();
System.out.print("
Employee salary is "+ hourlyRate*hours);
}

}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS