viraco4a

Salary_Original

Feb 7th, 2018
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace exam_Salary
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. double startingSalary = double.Parse(Console.ReadLine());
  14. int workingYears = int.Parse(Console.ReadLine());
  15. string sindicateInput = Console.ReadLine();
  16. bool sindicate = IsSindicate(sindicateInput);
  17. for (int i = 1; i <= workingYears; i++)
  18. {
  19. startingSalary = CalcSalary(startingSalary, i, sindicate);
  20. if (startingSalary >= 5000)
  21. {
  22. startingSalary = 5000;
  23. break;
  24. }
  25. }
  26. int j = 0;
  27. double potentialSalary = startingSalary;
  28. while (potentialSalary < 5000)
  29. {
  30. j++;
  31. potentialSalary = CalcSalary(potentialSalary, j + workingYears, sindicate);
  32. }
  33.  
  34. Console.WriteLine($"Current salary: {startingSalary:f2}");
  35. Console.WriteLine($"{j} more years to max salary.");
  36. }
  37.  
  38. private static double CalcSalary(double startingSalary, int i, bool sindicate)
  39. {
  40. startingSalary *= 1.06;
  41. if (i % 5 == 0)
  42. {
  43. startingSalary += 100;
  44. }
  45. if (i % 10 == 0)
  46. {
  47. startingSalary += 100;
  48. }
  49. if (i % 5 != 0 && sindicate)
  50. {
  51. startingSalary *= 0.99;
  52. }
  53.  
  54. return startingSalary;
  55. }
  56.  
  57. private static bool IsSindicate(string sindicateInput)
  58. {
  59. bool sindicate = false;
  60. if (sindicateInput == "Yes")
  61. {
  62. sindicate = true;
  63. }
  64.  
  65. return sindicate;
  66. }
  67. }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment