Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace _04Orders
- {
- class Program
- {
- static void Main(string[] args)
- {
- var products = new Dictionary<string, double>();
- var pricesOfProducts = new Dictionary<string, double>();
- string input = string.Empty;
- while ((input = Console.ReadLine()) != "buy")
- {
- string[] productInfo = input.Split();
- string productName = productInfo[0];
- double productPrice = double.Parse(productInfo[1]);
- double productQuantity = double.Parse(productInfo[2]);
- if (!products.ContainsKey(productName))
- {
- products.Add(productName, productQuantity);
- }
- else
- {
- products[productName] += productQuantity;
- }
- if (!pricesOfProducts.ContainsKey(productName))
- {
- pricesOfProducts.Add(productName, productPrice);
- }
- else
- {
- pricesOfProducts[productName] = productPrice;
- }
- products.Select(x => x.Value * productPrice).ToDictionary(x => x, x => true);
- }
- foreach (var kvp in products)
- {
- Console.WriteLine($"{kvp.Key} -> {kvp.Value:F2}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement