IvetValcheva

05. Salary

Nov 22nd, 2021
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.11 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp3
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int n = int.Parse(Console.ReadLine());
  10.             int salary = int.Parse(Console.ReadLine());
  11.  
  12.             double penalty = 0;
  13.  
  14.             for(int i = 1; i <= n; i++)
  15.             {
  16.                 string site = Console.ReadLine();
  17.  
  18.                 if (site == "Facebook")
  19.                 {
  20.                     penalty = penalty + 150;
  21.                 }
  22.                 else if (site == "Instagram")
  23.                 {
  24.                     penalty = penalty + 100;
  25.                 }
  26.                 else if(site == "Reddit")
  27.                 {
  28.                     penalty = penalty + 50;
  29.                 }
  30.  
  31.                 if (penalty >= salary)
  32.                 {
  33.                     break;
  34.                 }
  35.             }
  36.  
  37.             if (penalty >= salary)
  38.             {
  39.                 Console.WriteLine("You have lost your salary.");
  40.             }
  41.             else
  42.             {
  43.                 Console.WriteLine(salary-penalty);
  44.             }
  45.         }
  46.     }
  47. }
  48.  
Advertisement
Add Comment
Please, Sign In to add comment