Guest User

Untitled

a guest
Dec 14th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. // ***************************************************************
  2. // Salary.java
  3. // Computes the amount of a raise and the new salary for an
  4. // employee. The current salary and a performance rating
  5. // (a String: "Excellent", "Good", or "Poor") are input.
  6. // ***************************************************************
  7. import java.util.Scanner;
  8. import java.text.NumberFormat;
  9.  
  10. public class Salary
  11. {
  12. public static void main (String[] args)
  13. {
  14. double currentSalary; // employee's current salary
  15. double raise = 0; // amount of the raise
  16. double newSalary; // new salary for the employee
  17. String rating; // performance rating
  18. Scanner scan = new Scanner(System.in);
  19.  
  20. System.out.print ("Enter the current salary: ");
  21. currentSalary = scan.nextDouble();
  22. System.out.print ("Enter the performance rating (Excellent, "
  23. + " Good, or Poor): ");
  24. rating = scan.next();
  25.  
  26. // Compute the raise using if ...
  27. if (rating.equals("Excellent"))
  28. raise = currentSalary * .06;
  29. if (rating.equals("Good"))
  30. raise = currentSalary * .04;
  31. if (rating.equals("Poor"))
  32. raise = currentSalary * .015;
  33. newSalary = currentSalary + raise;
  34.  
  35. // Print the results
  36. NumberFormat money = NumberFormat.getCurrencyInstance();
  37. System.out.println();
  38. System.out.println("Current Salary: " + money.format(currentSalary));
  39. System.out.println("Amount of your raise: " + money.format(raise));
  40. System.out.println("Your new salary: " + money.format(newSalary));
  41. }
  42. }
Add Comment
Please, Sign In to add comment