static void Main(string[] args) { var rows = int.Parse(Console.ReadLine()); var salesArr = new Sale[rows]; for (int i = 0; i < rows; i++) { salesArr[i] = Sale.ReadSale(Console.ReadLine()); } Sale.PrintSalesReportByTown(salesArr); }
static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); List<Sale> sales = new List<Sale>(); for (int i = 0; i < n; i++) { var sale = Sale.ReadSale(); sales.Add(sale); } List<string> towns = sales.Select(s => s.Town).OrderBy(t => t).Distinct().ToList(); foreach (var t in towns) { var salesForT = sales.Where(s => s.Town == t).Sum(s => s.Price * s.Quantity); Console.WriteLine("{0} -> {1:f2}", t, salesForT); } }
static void Main(string[] args) { int count = int.Parse(Console.ReadLine()); var sales = new SortedDictionary <string, double>(); for (int i = 0; i < count; i++) { Sale sale = new Sale(); sale = sale.ReadSale(); if (sales.ContainsKey(sale.Town)) { sales[sale.Town] += (sale.Quantity * sale.Price); } else { sales[sale.Town] = sale.Quantity * sale.Price; } } foreach (var sale in sales) { Console.WriteLine($"{sale.Key:f2} -> {sale.Value:f2}"); } }