Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace _09.BankAccount
- {
- class BankAccount
- {
- public string Name { get; set; }
- public string Bank { get; set; }
- public decimal Balance { get; set; }
- public static BankAccount ReadAccount(string input)
- {
- string[] tokens = input.Split(new string[] { " | " }, StringSplitOptions.RemoveEmptyEntries);
- return new BankAccount
- {
- Name = tokens[1],
- Bank = tokens[0],
- Balance = decimal.Parse(tokens[2])
- };
- }
- }
- class Program
- {
- static void Main(string[] args)
- {
- string input = Console.ReadLine();
- List<BankAccount> result = new List<BankAccount>();
- while (input != "end")
- {
- BankAccount currAcc = BankAccount.ReadAccount(input);
- result.Add(currAcc);
- input = Console.ReadLine();
- }
- result.OrderByDescending(b => b.Balance).ThenBy(b => b.Bank.Length)
- .ToList().ForEach(x => Console.WriteLine($"{x.Name} -> {x.Balance} ({x.Bank})"));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement