Advertisement
tsvetelinapasheva

TsvetelinaPasheva/ForLoopExercise/06.Salary

Feb 1st, 2021
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.07 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp15
  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.             const int facebook = 150;
  13.             const int instagram = 100;
  14.             const int reddit = 50;
  15.             for (int i = 0; i < n; i++)
  16.             {
  17.                 string website = Console.ReadLine();
  18.                 if (website == "Facebook")
  19.                 {
  20.                     salary -= facebook;
  21.                 }
  22.                 else if (website == "Instagram")
  23.                 {
  24.                     salary -= instagram;
  25.                 }
  26.                 else if (website == "Reddit")
  27.                 {
  28.                     salary -= reddit;
  29.                 }
  30.             }
  31.             if (salary <= 0)
  32.             {
  33.                 Console.WriteLine("You have lost your salary.");
  34.             }
  35.             else
  36.             {
  37.                 Console.WriteLine(salary);
  38.             }
  39.         }
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement