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 ChristmasDecoration
- {
- class Program
- {
- static void Main(string[] args)
- {
- int budget = int.Parse(Console.ReadLine());
- string name = Console.ReadLine();
- int count = 0;
- while(name != "Stop")
- {
- foreach(char i in name)
- {
- count += i;
- }
- if (budget >= count)
- {
- budget -= count;
- Console.WriteLine($"Item successfully purchased!");
- count = 0;
- }
- else
- {
- Console.WriteLine("Not enough money!");
- return;
- }
- name = Console.ReadLine();
- }
- if(name == "Stop")
- {
- Console.WriteLine($"Money left: {budget}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement