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 _7.Andrey_and_billiard
- {
- class Program
- {
- static void Main(string[] args)
- {
- int n = int.Parse(Console.ReadLine());
- var productPrice = new Dictionary<string,double>();
- for (int i = 0; i < n; i++)
- {
- var currentText = Console.ReadLine().Split('-').ToArray();
- productPrice[currentText[0]] = double.Parse(currentText[1]);
- }
- var listCustomers = new List<Customer>();
- string nameProductQnty = Console.ReadLine();
- while (!nameProductQnty.Equals("end of clients"))
- {
- var takeNameArr = nameProductQnty.Split('-').ToArray();
- var takeproductQntyArr = takeNameArr[1].Split(',').ToArray();
- var cuurentCustomer = new Customer();
- cuurentCustomer.name = takeNameArr[0];
- cuurentCustomer.productQnty = new Dictionary<string, double>();
- cuurentCustomer.productQnty[takeproductQntyArr[0]] = double.Parse(takeproductQntyArr[1]);
- listCustomers.Add(cuurentCustomer);
- nameProductQnty = Console.ReadLine();
- }
- //---------------------------------------------------------------------------------------------
- var listBills = new List<double>();
- foreach (var item in listCustomers.OrderBy(x=>x.name))
- {
- foreach (var product in item.productQnty.Keys)
- {
- if (productPrice.Keys.Contains(product))
- {
- Console.WriteLine(item.name);
- Console.WriteLine($"-- {product} - {item.productQnty[product]}");
- Console.WriteLine("Bill: {0:f2}", item.productQnty[product]*productPrice[product]);
- listBills.Add(item.productQnty[product] * productPrice[product]);
- }
- }
- }
- var sumListBills = listBills.Sum();
- Console.WriteLine("Total bill: {0:f2}",sumListBills);
- //---------------------------------------------------------------------------------------------
- }
- }
- public class Customer
- {
- public string name { get; set; }
- public Dictionary<string, double> productQnty { get; set; }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment