Dianov

For Loop - Exercise (06. Salary)

Dec 27th, 2020
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.61 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 Salary
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int numberOfTabs = int.Parse(Console.ReadLine());
  14.             int salary = int.Parse(Console.ReadLine());
  15.             int deduction = 0;
  16.  
  17.             for (int i = 1; i <= numberOfTabs; i++)
  18.             {
  19.                 string siteName = Console.ReadLine();
  20.                 if (siteName == "Facebook")
  21.                 {
  22.                     deduction += 150;
  23.                     if ((salary - deduction) <= 0)
  24.                     {
  25.                         Console.WriteLine("You have lost your salary.");
  26.                         break;
  27.                     }
  28.                 }
  29.                 else if (siteName == "Instagram")
  30.                 {
  31.                     deduction += 100;
  32.                     if ((salary - deduction) <= 0)
  33.                     {
  34.                         Console.WriteLine("You have lost your salary.");
  35.                         break;
  36.                     }
  37.                 }
  38.                 else if (siteName == "Reddit")
  39.                 {
  40.                     deduction += 50;
  41.                     if ((salary - deduction) <= 0)
  42.                     {
  43.                         Console.WriteLine("You have lost your salary.");
  44.                         break;
  45.                     }
  46.                 }
  47.             }
  48.             if ((salary - deduction) > 0)
  49.             {
  50.                 Console.WriteLine(salary - deduction);
  51.             }
  52.         }  
  53.     }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment