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[]>();
- string input = string.Empty;
- while ((input = Console.ReadLine()) != "buy")
- {
- string[] tokens = input.Split();
- string name = tokens[0];
- double price = double.Parse(tokens[1]);
- double quantity = double.Parse(tokens[2]);
- if (!products.ContainsKey(name))
- {
- products[name] = new double[2];
- }
- products[name][0] = price;
- products[name][1] += quantity;
- }
- foreach (var product in products)
- {
- Console.WriteLine($"{product.Key} -> {(product.Value[0] * product.Value[1]):F2}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement