viraco4a

Salaryt_with_scam

Feb 7th, 2018
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.23 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. double potentialSalary = startingSalary;
  27. if (potentialSalary == 5000)
  28. {
  29. Console.WriteLine($"Current salary: {startingSalary:f2}");
  30. Console.WriteLine($"{0} more years to max salary.");
  31. }
  32. else
  33. {
  34. int j = 0;
  35. while (potentialSalary < 5000)
  36. {
  37. j++;
  38. potentialSalary = CalcSalary(potentialSalary, j + workingYears, sindicate);
  39. }
  40. Console.WriteLine($"Current salary: {startingSalary:f2}");
  41. Console.WriteLine($"{j - 1} more years to max salary.");
  42. }
  43. }
  44.  
  45. private static double CalcSalary(double startingSalary, int i, bool sindicate)
  46. {
  47. startingSalary *= 1.06;
  48. if (i % 5 == 0)
  49. {
  50. startingSalary += 100;
  51. }
  52. if (i % 10 == 0)
  53. {
  54. startingSalary += 100;
  55. }
  56. if (i % 5 != 0 && sindicate)
  57. {
  58. startingSalary *= 0.99;
  59. }
  60.  
  61. return startingSalary;
  62. }
  63.  
  64. private static bool IsSindicate(string sindicateInput)
  65. {
  66. bool sindicate = false;
  67. if (sindicateInput == "Yes")
  68. {
  69. sindicate = true;
  70. }
  71.  
  72. return sindicate;
  73. }
  74. }
  75. }
Advertisement
Add Comment
Please, Sign In to add comment