VladoG

PB-BG-Oct2018-ExamPrep-05.FanShop

Nov 24th, 2018
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.35 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _05.FanShop
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int budget = int.Parse(Console.ReadLine());
  10.             int qty = int.Parse(Console.ReadLine());
  11.             int totalSum = 0;
  12.  
  13.             for (int i = 0; i < qty; i++)
  14.             {
  15.                 string article = Console.ReadLine();
  16.  
  17.                 switch (article)
  18.                 {
  19.                     case "hoodie":
  20.                         totalSum +=30;
  21.                         break;
  22.                     case "keychain":
  23.                         totalSum += 4;
  24.                         break;
  25.                     case "T-shirt":
  26.                         totalSum += 20;
  27.                         break;
  28.                     case "flag":
  29.                         totalSum += 15;
  30.                         break;
  31.                     case "sticker":
  32.                         totalSum += 1;
  33.                         break;
  34.                     default: break;
  35.                 }
  36.             }
  37.  
  38.             if (budget >= totalSum)
  39.             {
  40.                 Console.WriteLine($"You bought {qty} items and left with {budget - totalSum} lv.");
  41.             }
  42.             else
  43.             {
  44.                 Console.WriteLine($"Not enough money, you need {totalSum - budget} more lv.");
  45.             }
  46.         }
  47.     }
  48. }
Add Comment
Please, Sign In to add comment