Advertisement
Guest User

Untitled

a guest
Jul 19th, 2017
269
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace ConsoleApplication67
  6. {
  7. internal class Program
  8. {
  9. private static void Main(string[] args)
  10. {
  11. var budget = decimal.Parse(Console.ReadLine());
  12. var productPrice = new Dictionary<string, decimal>();
  13. var input = Console.ReadLine();
  14. while (input != "end")
  15. {
  16. var inputArgs = input.Split(' ');
  17. productPrice[inputArgs[0]] = decimal.Parse(inputArgs[1]);
  18. input = Console.ReadLine();
  19. }
  20. if (productPrice.Sum(x => x.Value) > budget)
  21. Console.WriteLine("Need more money... Just buy banichka");
  22. else
  23. foreach (var kvp in productPrice.OrderByDescending(x => x.Value).ThenBy(x => x.Key.Length))
  24. Console.WriteLine($"{kvp.Key} costs {kvp.Value:F2}");
  25. }
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement