Advertisement
Guest User

asd

a guest
Dec 16th, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.37 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 Book_library
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. List<Customer>customers = new List<Customer>();
  14. Dictionary<string, decimal>shop = new Dictionary<string, decimal>();
  15. int n = int.Parse(Console.ReadLine());
  16. for (int i = 0; i < n; i++)
  17. {
  18. string[] tokens = Console.ReadLine().Split('-').ToArray();
  19. if (!shop.ContainsKey(tokens[0]))
  20. {
  21. shop.Add(tokens[0], decimal.Parse(tokens[1]));
  22. }
  23. else
  24. {
  25. shop[tokens[0]] = decimal.Parse(tokens[1]);
  26. }
  27. }
  28. string input = Console.ReadLine();
  29. while (input != "end of clients")
  30. {
  31. string[] tokens = Console.ReadLine().Split(new char[] { '-', ',' }, StringSplitOptions.RemoveEmptyEntries).ToArray();
  32. if (shop.ContainsKey(tokens[1]))
  33. {
  34. var primerno = new KeyValuePair<string, int>(tokens[1], int.Parse(tokens[2]));
  35. Customer customer = new Customer(){Name = tokens[0], ShopList = primerno};
  36. foreach (var item in shop)
  37. {
  38. if (item.Key.Equals(tokens[1]))
  39. {
  40. customer.Bill = item.Value * decimal.Parse(tokens[2]);
  41. }
  42. }
  43. customers.Add(customer);
  44. }
  45. input = Console.ReadLine();
  46. }
  47. decimal totalBill = 0;
  48. foreach (var customer in customers)
  49. {
  50. totalBill += customer.Bill;
  51. Console.WriteLine(customer.Name);
  52. Console.WriteLine($"-- {customer.ShopList.Key} - {customer.ShopList.Value}");
  53. Console.WriteLine($"Bill: {customer.Bill:f2}");
  54. Console.WriteLine($"Totall bill: {totalBill:f2}");
  55. }
  56. }
  57. }
  58. public class Customer
  59. {
  60. public KeyValuePair<string, int> ShopList { get; set; }
  61. public decimal Bill { get; set; }
  62. public string Name { get; set; }
  63. }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement