Advertisement
Guest User

Book Library - without sum

a guest
Sep 11th, 2016
327
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _5.Book_Library
  8. {
  9. class Book
  10. {
  11. public string title { get; set; }
  12. public string author { get; set; }
  13. public string publisher { get; set; }
  14. public string releaseDate { get; set; }
  15. public string ISBNnumber { get; set; }
  16. public decimal price { get; set; }
  17. }
  18.  
  19. class Library
  20. {
  21. public string name { get; set; }
  22. public List<Book> books { get; set; }
  23. }
  24.  
  25. class BookLibrary
  26. {
  27. static void Main(string[] args)
  28. {
  29. Library myLibrary = new Library();
  30. myLibrary.books = new List<Book>();
  31. int numberOfBooks = int.Parse(Console.ReadLine());
  32. myLibrary.name = "Yavor's library";
  33. for (int book = 0; book < numberOfBooks; book++)
  34. {
  35. string[] data = Console.ReadLine().Split().ToArray();
  36. string title = data[0];
  37. string author = data[1];
  38. string publisher = data[2];
  39. string releaseDate = data[3];
  40. string ISBNnumber = data[4];
  41. decimal price = decimal.Parse(data[5]);
  42. Book myBook = new Book();
  43. myBook.title = title;
  44. myBook.author = author;
  45. myBook.publisher = publisher;
  46. myBook.releaseDate = releaseDate;
  47. myBook.ISBNnumber = ISBNnumber;
  48. myBook.price = price;
  49. myLibrary.books.Add(myBook);
  50. }
  51. myLibrary.books.OrderByDescending(x => x.price).ThenBy(x=>x.author);
  52. foreach (var book in myLibrary.books)
  53. {
  54. Console.WriteLine("{0:f2} -> {1:f2}", book.author, book.price);
  55. }
  56. }
  57. }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement