using System.Collections.Generic;
public string Description;
public static void Main()
int total_orders = 0; int total_orders_under_500 = 0; int total_orders_over_500 = 0;
decimal order_costs = 0.0M; decimal order_costs_under_30 = 0.0M; decimal order_costs_over_30 = 0.0M;
List<Customer> customers = new List<Customer>()
new Customer(){ID = Guid.NewGuid(), Age = 23, First = "Joe", Last = "Smith"},
new Customer(){ID = Guid.NewGuid(), Age = 34, First = "Kevin", Last = "Costner"},
new Customer(){ID = Guid.NewGuid(), Age = 23, First = "Sally", Last = "Smuthers"},
new Customer(){ID = Guid.NewGuid(), Age = 56, First = "Mary", Last = "Jane"},
new Customer(){ID = Guid.NewGuid(), Age = 48, First = "Jane", Last = "Kendall"},
new Customer(){ID = Guid.NewGuid(), Age = 34, First = "Eve", Last = "Shrimp"},
new Customer(){ID = Guid.NewGuid(), Age = 31, First = "Donna", Last = "Lynn"},
new Customer(){ID = Guid.NewGuid(), Age = 21, First = "Sarah", Last = "Spicer"},
List<Order> orders = new List<Order>()
new Order() {CustomerID = customers[0].ID, Description="Shoes", Price=150.23M, Quantity=1},
new Order() {CustomerID = customers[0].ID, Description="Phone", Price=130.25M, Quantity=1},
new Order() {CustomerID = customers[0].ID, Description="Jacket", Price=230.14M, Quantity=1},
new Order() {CustomerID = customers[1].ID, Description="Phone", Price=130.25M, Quantity=1},
new Order() {CustomerID = customers[1].ID, Description="Jacket", Price=230.14M, Quantity=1},
new Order() {CustomerID = customers[1].ID, Description="Pants", Price=70.56M, Quantity=1},
new Order() {CustomerID = customers[2].ID, Description="Jacket", Price=230.14M, Quantity=1},
new Order() {CustomerID = customers[2].ID, Description="Pants", Price=70.56M, Quantity=1},
new Order() {CustomerID = customers[2].ID, Description="Shirt", Price=49.99M, Quantity=1},
new Order() {CustomerID = customers[3].ID, Description="Pants", Price=70.56M, Quantity=1},
new Order() {CustomerID = customers[3].ID, Description="Shirt", Price=49.99M, Quantity=1},
new Order() {CustomerID = customers[3].ID, Description="Scarf", Price=23.69M, Quantity=1},
new Order() {CustomerID = customers[4].ID, Description="Shirt", Price=49.99M, Quantity=1},
new Order() {CustomerID = customers[4].ID, Description="Scarf", Price=23.69M, Quantity=1},
new Order() {CustomerID = customers[4].ID, Description="Car", Price=24200.15M, Quantity=1},
new Order() {CustomerID = customers[5].ID, Description="Scarf", Price=23.69M, Quantity=1},
new Order() {CustomerID = customers[5].ID, Description="Car", Price=24200.15M, Quantity=1},
new Order() {CustomerID = customers[5].ID, Description="Computer", Price=650.00M, Quantity=1},
new Order() {CustomerID = customers[6].ID, Description="Car", Price=24200.15M, Quantity=1},
new Order() {CustomerID = customers[6].ID, Description="Computer", Price=650.00M, Quantity=1},
new Order() {CustomerID = customers[6].ID, Description="Shoes", Price=150.23M, Quantity=1},
new Order() {CustomerID = customers[7].ID, Description="Computer", Price=650.00M, Quantity=1},
new Order() {CustomerID = customers[7].ID, Description="Jacket", Price=230.14M, Quantity=1},
new Order() {CustomerID = customers[7].ID, Description="Pants", Price=70.56M, Quantity=1},
join ord in orders on cust.ID equals ord.CustomerID into order_group
LastName = cust.Last, FirstName = cust.First, Age = cust.Age,
Products = from orde in order_group
orderby orde.Price descending
select new { order_description = order.Description, order_price = order.Price };
var least_expensive_products = price_of_orders.OrderBy(n => n.order_price).Distinct().Take(3);
var most_expensive_products = price_of_orders.OrderByDescending(n => n.order_price).Distinct().Take(3);
foreach (var product_type in query)
Console.WriteLine(product_type.FirstName+" " + product_type.LastName);
Console.WriteLine("Orders:");
total_orders= total_orders + product_type.Products.Count();
total_orders_under_500 = total_orders_under_500 + product_type.Products.Count(n => n.Price <= 500.00M);
total_orders_over_500 = total_orders_over_500 + product_type.Products.Count(n => n.Price > 500.00M);
order_costs = order_costs + product_type.Products.Sum(n=>n.Price);
if (product_type.Age <= 30)
order_costs_under_30 = order_costs_under_30 + product_type.Products.Sum(n => n.Price);
if (product_type.Age > 30)
order_costs_over_30 = order_costs_over_30 + product_type.Products.Sum(n => n.Price);
foreach (var prodItem in product_type.Products)
Console.WriteLine(prodItem.Description + " Price: " + prodItem.Price + " Quantity: "+ prodItem.Quantity);
Console.WriteLine("===================");
Console.WriteLine("Total number of orders: " + total_orders);
Console.WriteLine("Number of orders $500 or Under: "+ total_orders_under_500);
Console.WriteLine("Number of orders over $500: " + total_orders_over_500);
Console.WriteLine("Total cost of all orders: " + order_costs);
Console.WriteLine("Total cost for all orders for people 30 or under: " + order_costs_under_30);
Console.WriteLine("Total cost for all orders for people over 30: " + order_costs_over_30);
Console.WriteLine("The 3 least expensive products: ");
foreach (var product_name in least_expensive_products)
Console.WriteLine("Price: {0}, Description : {1} ", product_name.order_price, product_name.order_description);
Console.WriteLine("The 3 most expensive products:");
foreach (var product_name in most_expensive_products)
Console.WriteLine("Price: {0}, Description : {1} ", product_name.order_price, product_name.order_description);