Advertisement
Guest User

Untitled

a guest
Mar 6th, 2020
970
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace _04._Orders
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. var check = new Dictionary<string, List<string>>();
  12. while (true)
  13. {
  14. string[] input = Console.ReadLine().Split(' ').ToArray();
  15. string key = input[0];
  16. if (key=="buy")
  17. {
  18. foreach (var product in check)
  19. {
  20. double money = double.Parse(product.Value[0]) * double.Parse(product.Value[1]);
  21.  
  22. product.Value[0] = $"{money:f2}";
  23. product.Value.RemoveAt(1);
  24. }
  25. break;
  26. }
  27. string price = input[1];
  28. string count = input[2];
  29. if (!check.ContainsKey(input[0]))
  30. {
  31. check.Add(key,new List<string> { price,count} );
  32. }
  33. else
  34. {
  35. check[key][0] = price;
  36. check[key][1] += count;
  37. }
  38. }
  39. foreach (var product in check)
  40. {
  41. Console.WriteLine($"{product.Key} -> {product.Value}");
  42. }
  43. }
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement