Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace _5_Fan_Shop
- {
- class Program
- {
- static void Main(string[] args)
- {
- int budget = int.Parse(Console.ReadLine());
- int numberOfItems = int.Parse(Console.ReadLine());
- int totalPrice = 0;
- for (int i = 0; i < numberOfItems; i++)
- {
- string item = Console.ReadLine();
- if (item == "hoodie")
- {
- totalPrice += 30;
- }
- else if (item == "keychain")
- {
- totalPrice += 4;
- }
- else if (item == "T-shirt")
- {
- totalPrice += 20;
- }
- else if (item == "flag")
- {
- totalPrice += 15;
- }
- else if(item== "sticker")
- {
- totalPrice++;
- }
- }
- if (budget >= totalPrice)
- {
- int moneyLeft = budget - totalPrice;
- Console.WriteLine($"You bought {numberOfItems} items and left with {moneyLeft} lv.");
- }
- else
- {
- int moneyNeed = Math.Abs(budget - totalPrice);
- Console.WriteLine($"Not enough money, you need {moneyNeed} more lv.");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement