Question
Computing a Raise Complete the program below to determine the raise and new salary for an employee by adding if ... else statements to compute
Computing a Raise
Complete the program below to determine the raise and new salary for an employee by adding if ... else statements to compute the raise. The input to the program includes the current annual salary for the employee and a number indicating the performance rating (1=excellent, 2=good, and 3=poor). An employee with a rating of 1 will receive a 6% raise, an employee with a rating of 2 will receive a 4% raise, and one with a rating of 3 will receive a 1.5% raise.
// ************************************************************ // Salary1.java // To compute the raise and new salary for an employee // ************************************************************
import java.util.Scanner; import java.text.NumberFormat;
public class Salary1 {
public static void main (String[] args) { double currentSalary; // current annual salary int rating; // performance rating double raise; // dollar amount of the raise double newSalary; // new salary for the employee
Scanner scan = new Scanner(System.in); // Get the current salary and performance rating System.out.print ("Enter the current salary: "); currentSalary = scan.nextDouble();
System.out.print ("Enter the performance rating: " + "Enter 1 for Excellent, 2 for Good, or 3 for Poor: "); //rating =
// Compute the raise -- Use if ... else ... (20 pts)
// Print the results NumberFormat money = NumberFormat.getCurrencyInstance();
System.out.println("Current Salary: " + money.format(currentSalary)); System.out.println("Amount of your raise: " + money.format(raise)); System.out.println( "Your new salary: " + money.format(newSalary)); System.out.println();
} }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started