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.
1
Expert's answer
2012-12-11T09:20:38-0500
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); }
Comments
Leave a comment