Advertisement
desislava_topuzakova

Untitled

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