Advertisement
Guest User

Untitled

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