Salary - "); rating = scan.next(); // Compute...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
// *************************************************************** // Salary.java // // Computes the amount of a raise and the new // salary for an employee. The current salary // and a performance rating (a String: "Excellent", // "Good" or "Poor") are input. // *************************************************************** import java.util.Scanner; import java.text.NumberFormat; public class Salary { public static void main (String[] args) { double currentSalary; // employee's current salary double raise; // amount of the raise double newSalary; // new salary for the employee String rating; // performance rating Scanner scan = new Scanner (System.in); System.out.print ("Enter the current salary: "); currentSalary = scan.nextDouble(); System.out.print ("Enter the performance rating (Excellent, Good, or Poor):
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: "); rating = scan.next(); // Compute the raise using if . .. if (rating.equals("Excellent")) raise = currentSalary * 0.06; else if (rating.equals("Good")) raise = currentSalary * 0.04; else if (rating.equals("Poor")) raise = currentSalary * 0.015; else { raise = 0; System.out.println("Illegal response, no raise given."); } newSalary = currentSalary + raise; // Print the results NumberFormat money = NumberFormat.getCurrencyInstance(); System.out.println(); 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(); } }...
View Full Document

Ask a homework question - tutors are online