xunap

4.Salary

Jul 6th, 2018
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.78 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 programka
  8.  
  9.  
  10. {
  11.     class Program
  12.     {
  13.         static void Main(string[] args)
  14.         {
  15.             double salary = double.Parse(Console.ReadLine());
  16.             int timeWorked = int.Parse(Console.ReadLine());
  17.             string member = Console.ReadLine();
  18.  
  19.             double currentSalary = 0;
  20.             int years = 0;
  21.  
  22.             for (int i = 1; i <= 1000; i++)
  23.             {
  24.                 salary = salary + (salary * 0.06);
  25.                 if (member == "Yes" && i % 10 != 5 && i % 10 != 0)
  26.                 {
  27.                     salary = salary - (salary * 0.01);
  28.                 }
  29.                 if (i % 10 == 5)
  30.                 {
  31.                     salary += 100;
  32.                 }
  33.                 if (i % 10 == 0)
  34.                 {
  35.                     salary += 200;
  36.                 }
  37.            
  38.                 currentSalary = salary;                        
  39.                            
  40.                 if (i == timeWorked && currentSalary < 5000)
  41.                 {
  42.                     Console.WriteLine($"Current salary: {currentSalary:f2}");
  43.                 }
  44.                 else if (currentSalary >= 5000 && timeWorked >= i)
  45.                 {
  46.                     Console.WriteLine($"Current salary: {5000:f2}");
  47.                     Console.WriteLine($"{0} more years to max salary.");
  48.                     break;
  49.                 }
  50.                 if (currentSalary >= 5000)
  51.                 {
  52.                     years = i - 1 - timeWorked;
  53.                     Console.WriteLine($"{years} more years to max salary.");
  54.                     break;
  55.                 }                            
  56.             }
  57.         }
  58.     }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment