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.Text;
- using System.Threading.Tasks;
- namespace _09.BankAccount
- {
- class Program
- {
- static void Main(string[] args)
- {
- string input = Console.ReadLine();
- List<BankAccount> result = new List<BankAccount>();
- while (input != "end")
- {
- BankAccount currAcc = ReadAccount(input);
- result.Add(currAcc);
- input = Console.ReadLine();
- }
- result = result.OrderByDescending(b => b.Balance).ThenBy(n => n.Bank.Length).ToList();
- foreach (var item in result)
- {
- Console.WriteLine($"{item.Name} -> {item.Balance} ({item.Bank})");
- }
- }
- private static BankAccount ReadAccount(string input)
- {
- string[] tokens = input.Split(new string[] { " | " }, StringSplitOptions.RemoveEmptyEntries).ToArray();
- return new BankAccount
- {
- Name = tokens[1],
- Bank = tokens[0],
- Balance = decimal.Parse(tokens[2])
- };
- }
- }
- class BankAccount
- {
- public string Name { get; set; }
- public string Bank { get; set; }
- public decimal Balance { get; set; }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement