Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Net;
- using System.Globalization;
- namespace Box
- {
- class Box
- {
- public string Name { get; set; }
- public decimal Price { get; set; }
- public string SerialNumber { get; set; }
- public int Quantity { get; set; }
- public decimal BoxPrice { get; set; }
- public Box(string name, decimal price, string serialNumber, int quantity, decimal boxPrice)
- {
- this.Name = name;
- this.Price = price;
- this.SerialNumber = serialNumber;
- this.Quantity = quantity;
- this.BoxPrice = boxPrice;
- }
- public override string ToString()
- {
- return $@"{this.SerialNumber}
- -- {this.Name} - ${this.Price:f2}: {this.Quantity}
- -- ${this.BoxPrice:f2}";
- }
- }
- class MainClass
- {
- public static void Main(string[] args)
- {
- List<Box> box = new List<Box>();
- string input;
- while ((input = Console.ReadLine()) != "end")
- {
- string[] data = input.Split();
- string serialNumber = data[0];
- string name = data[1];
- int quantity = int.Parse(data[2]);
- decimal price = decimal.Parse(data[3]);
- decimal boxPrice = price * quantity;
- Box newBox = new Box(name, price, serialNumber, quantity, boxPrice);
- box.Add(newBox);
- }
- box = box.OrderByDescending(x => x.BoxPrice).ToList();
- Console.WriteLine(string.Join(Environment.NewLine, box));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement