using System.Collections.Generic;
namespace ProductManagement
public int Id { get; set; }
public string Name { get; set; }
public string Category { get; set; }
public decimal Price { get; set; }
public class ProductOperations
public List<Product> Products { get; set; }
public ProductOperations(List<Product> products)
public List<string> GetCategoriesWithMostExpensiveProduct()
throw new NotImplementedException();
public List<Product> GetProductsAboveAveragePrice()
throw new NotImplementedException();
public Dictionary<string, (decimal MinPrice, decimal MaxPrice)> GetCategoryPriceStats()
throw new NotImplementedException();
public List<string> GetProductNamesInDistinctCategories()
throw new NotImplementedException();
public Dictionary<string, int> GetProductCountByCategory()
throw new NotImplementedException();
static void Main(string[] args)
List<Product> products = new List<Product>
new Product { Id = 1, Name = "Laptop", Category = "Electronics", Price = 1200 },
new Product { Id = 2, Name = "Smartphone", Category = "Electronics", Price = 800 },
new Product { Id = 3, Name = "Tablet", Category = "Electronics", Price = 600 },
new Product { Id = 4, Name = "Headphones", Category = "Accessories", Price = 150 },
new Product { Id = 5, Name = "Charger", Category = "Accessories", Price = 50 },
new Product { Id = 6, Name = "Desk", Category = "Furniture", Price = 300 },
new Product { Id = 7, Name = "Chair", Category = "Furniture", Price = 200 },
ProductOperations productOperations = new ProductOperations(products);
var mostExpensiveCategories = productOperations.GetCategoriesWithMostExpensiveProduct();
var productsAboveAveragePrice = productOperations.GetProductsAboveAveragePrice();
var categoryPriceStats = productOperations.GetCategoryPriceStats();
var distinctCategoryProductNames = productOperations.GetProductNamesInDistinctCategories();
var productCountByCategory = productOperations.GetProductCountByCategory();
Console.WriteLine("Categories with the most expensive product:");
mostExpensiveCategories.ForEach(Console.WriteLine);
Console.WriteLine("\nProducts with price above average:");
productsAboveAveragePrice.ForEach(p => Console.WriteLine(p.Name));
Console.WriteLine("\nCategory price stats:");
foreach (var stat in categoryPriceStats)
Console.WriteLine($"{stat.Key}: MinPrice = {stat.Value.MinPrice}, MaxPrice = {stat.Value.MaxPrice}");
Console.WriteLine("\nProduct names in distinct categories:");
distinctCategoryProductNames.ForEach(Console.WriteLine);
Console.WriteLine("\nProduct count by category:");
foreach (var count in productCountByCategory)
Console.WriteLine($"{count.Key}: {count.Value}");