Advertisement
desislava_topuzakova

Salary2

Feb 9th, 2018
404
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1.  
  2. import java.util.Scanner;
  3.  
  4.  
  5. public class Salary {
  6. public static void main(String[] args) throws IOException {
  7. Scanner scan = new Scanner(System.in);
  8.  
  9. double salary = Double.parseDouble(scan.nextLine());
  10. int years = Integer.parseInt(scan.nextLine());
  11. String syndicate = scan.nextLine();
  12.  
  13. int currentYear = 0;
  14. double currentSalary = salary;
  15.  
  16. if(salary >= 5000){
  17. System.out.println("Current salary: 5000.00");
  18. System.out.println("0 more years to max salary.");
  19. return;
  20. }
  21. while(currentSalary <= 5000){
  22.  
  23. currentYear++;
  24.  
  25. currentSalary += currentSalary * 0.06;
  26.  
  27. if(currentYear % 10 == 0){
  28. currentSalary += 200;
  29. }
  30. else if(currentYear % 5 == 0){
  31. currentSalary += 100;
  32. }
  33.  
  34. else if(syndicate.equalsIgnoreCase("yes")) {
  35. currentSalary -= currentSalary * 0.001;
  36. }
  37.  
  38. if(currentSalary >= 5000 && currentYear <= years){
  39. salary = 5000;
  40. currentYear = years + 1;
  41. break;
  42. }
  43.  
  44. if(currentYear == years){
  45. salary = currentSalary;
  46. }
  47. }
  48.  
  49.  
  50.  
  51. System.out.printf("Current salary: %.2f\n", salary);
  52. System.out.printf("%d more years to max salary.", (currentYear - years) - 1);
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement