U.S. federal govt. employees are paid on a scale according to their grade and st
ID: 3542687 • Letter: U
Question
U.S. federal govt. employees are paid on a scale according to their grade and step. There are a total of 15 grades, each of which consists of 10 steps. Here's a table of 2012 annual salaries (in $) for the first 5 grades and the first 3 steps from each:
Grade Step 1 Step2 Step3
1 20324 21008 21679
2 22851 23395 24151
3 24933 25764 26595
4 27990 28922 29855
5 31315 32359 33402
Write a Java program that uses conditionals to determine the salary of an employee.
Your program should allow the user to enter two inputs: the grade and step.
It should then display the appropriate salary based on the table above. Include default cases to cover situations where the user enters an invalid grade or step.
You can use either if/else or the switch statement to accomplish this task. In the comments of your program, explain why you choose one or the other.
Explanation / Answer
import java.util.Scanner;class switch{public static void main(String[] args){int season =0;Scanner sc =new Scanner (System.in);System.out.println();System.out.println("Enter the season number"); season = sc.nextInt(); switch(season){case 1:System.out.println("Jan");break;case 2:System.out.println("Feb");break;case 3:System.out.println("mar");break;case 4:System.out.println("Apr");break;case 5:System.out.println("May");break;case 6:System.out.println("June");break;case 7:System.out.println("July");break;case 8:System.out.println("Aug");break;case 9:System.out.println("Sep");break;case 10:System.out.println("Oct");break;case 11:System.out.println("Nov");break;case 12:System.out.println("Dec");break;default:System.out.println("Not Session Data Found!!!");break;}}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.