Code
Code
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
class Sale
{
public DateTime Date { get; set; }
public string SKU { get; set; }
public decimal UnitPrice { get; set; }
public int Quantity { get; set; }
public decimal TotalPrice { get; set; }
public Sale(string date, string sku, decimal unitPrice, int quantity, decimal
totalPrice)
{
Date = DateTime.ParseExact(date, "yyyy-MM-dd",
CultureInfo.InvariantCulture);
SKU = sku;
UnitPrice = unitPrice;
Quantity = quantity;
TotalPrice = totalPrice;
}
}
// Total sales
decimal totalSales = sales.Sum(s => s.TotalPrice);
Console.WriteLine($"Total Sales: {totalSales}");