Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace classes
- {
- class Item
- {
- public string Name { get; set; }
- public decimal PriceItem { get; set; }
- }
- class Box
- {
- //Serial Number, Item, Item Quantity and Price for a Box.
- public string SerialNumber { get; set; }
- public Item Item { get; set; }
- public int Quantity { get; set; }
- public decimal Price { get; set; }
- public Box()
- {
- Item = new Item();
- }
- }
- class Program
- {
- static void Main(string[] args)
- {
- //{Serial Number} {Item Name} {Item Quantity} {itemPrice}
- string[] input = Console.ReadLine().Split().ToArray();
- List<Box> list = new List<Box>();
- while (input[0] != "end")
- {
- string serial = input[0];
- string name = input[1];
- int quantity = int.Parse(input[2]);
- decimal price = decimal.Parse(input[3]);
- Box box = new Box();
- box.Item = new Item();
- box.SerialNumber = serial;
- box.Quantity = quantity;
- box.Price = price * quantity;
- box.Item.Name = name;
- box.Item.PriceItem = price;
- list.Add(box);
- input = Console.ReadLine().Split().ToArray();
- }
- foreach (var box in list.OrderByDescending(x => x.Price))
- {
- Console.WriteLine(box.SerialNumber);
- Console.WriteLine($"-- {box.Item.Name} – ${box.Item.PriceItem:f2}: {box.Quantity}");
- Console.WriteLine($"-- ${box.Price}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement