Answer to Question #20407 in Java | JSP | JSF for shalenee

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.
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);
}

}

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!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS