Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Globalization;
- using System.Linq;
- namespace _4.Orders
- {
- class Program
- {
- static void Main(string[] args)
- {
- var dict = new Dictionary<string, List<double>>();
- while (true)
- {
- var arrayCommand = Console.ReadLine()
- .Split()
- .ToList();
- if (arrayCommand[0] == "buy")
- {
- break;
- }
- string command = arrayCommand[0];
- double priceValue = double.Parse(arrayCommand[1]);
- double quantityValue = double.Parse(arrayCommand[2]);
- if (!dict.ContainsKey(command))
- {
- dict.Add(command, new List<double>());
- }
- dict[command].Add(priceValue);
- // here's the issue dict[command].Insert(1, quantityValue);
- // how to add the sum at index 1 of the list(values) ? The calculation above is incorrect;
- //listProduct[product][1] += quantity;= that does not work
- // with lists , only with [](array)
- }
- foreach (var item in dict)
- {
- Console.WriteLine($"{item.Key} -> {(item.Value[0] * item.Value[1]):f2}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement