Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.54 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 _5_Fan_Shop
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int budget = int.Parse(Console.ReadLine());
  14.             int numberOfItems = int.Parse(Console.ReadLine());
  15.  
  16.             int totalPrice = 0;
  17.             for (int i = 0; i < numberOfItems; i++)
  18.             {
  19.                 string item = Console.ReadLine();
  20.                 if (item == "hoodie")
  21.                 {
  22.                     totalPrice += 30;
  23.                 }
  24.                 else if (item == "keychain")
  25.                 {
  26.                     totalPrice += 4;
  27.                 }
  28.                 else if (item == "T-shirt")
  29.                 {
  30.                     totalPrice += 20;
  31.                 }
  32.                 else if (item == "flag")
  33.                 {
  34.                     totalPrice += 15;
  35.                 }
  36.                 else if(item== "sticker")
  37.                 {
  38.                     totalPrice++;
  39.                 }
  40.  
  41.              
  42.             }
  43.             if (budget >= totalPrice)
  44.             {
  45.                 int moneyLeft = budget - totalPrice;
  46.                 Console.WriteLine($"You bought {numberOfItems} items and left with {moneyLeft} lv.");
  47.  
  48.             }
  49.             else
  50.             {
  51.                 int moneyNeed = Math.Abs(budget - totalPrice);
  52.                 Console.WriteLine($"Not enough money, you need {moneyNeed} more lv.");
  53.             }
  54.  
  55.         }
  56.     }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement