velikova_olya

Salary

Mar 8th, 2018
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. package LoopsExams;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Salary {
  6. public static void main(String[] args) {
  7. Scanner scanner = new Scanner(System.in);
  8.  
  9. double basicSalaryFirstYear = Double.parseDouble(scanner.nextLine());
  10. int totalYears = Integer.parseInt(scanner.nextLine());
  11. String syndicateMember = scanner.nextLine();
  12. double currentSalary = basicSalaryFirstYear;
  13. int counter = 0;
  14. double maxSalary = 5000.00;
  15.  
  16. for (int i = 1; i <= 100; i++) {
  17. counter++;
  18. currentSalary = currentSalary + currentSalary * 0.06;
  19.  
  20. if (counter % 10 == 5) {
  21. currentSalary += 100;
  22. }
  23. if (counter % 10 == 0) {
  24. currentSalary += 200;
  25. }
  26. if (syndicateMember.equals("Yes")) {
  27. if (counter % 10 != 0 && counter % 10 != 5) {
  28. currentSalary = currentSalary - currentSalary * 0.01;
  29. }
  30. }
  31. if (currentSalary >= maxSalary && i <= totalYears) {
  32. System.out.println("Current salary: 5000.00");
  33. System.out.println("0 more years to max salary.");
  34. return;
  35. }
  36. if (i == totalYears) {
  37. System.out.printf("Current salary: %.2f%n", currentSalary);
  38. }
  39. if (currentSalary >= maxSalary) {
  40. System.out.printf("%d more years to max salary.", i - 1 - totalYears);
  41. return;
  42. }
  43. }
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment