Advertisement
vasilevaiva

Untitled

Apr 5th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 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 FavoriteBook
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. string favouriteBook = Console.ReadLine();
  14. int numberOfBooks = int.Parse(Console.ReadLine());
  15. int counter = 0;
  16. bool bookIsFound = false;
  17.  
  18. string nextBookName = Console.ReadLine();
  19. while (counter < numberOfBooks)
  20. {
  21. nextBookName = Console.ReadLine();
  22. }
  23. while (counter < numberOfBooks)
  24. {
  25.  
  26. if (nextBookName == favouriteBook)
  27. {
  28. bookIsFound = true;
  29. break;
  30. }
  31. else if (nextBookName != favouriteBook)
  32.  
  33. counter++;
  34.  
  35. nextBookName = Console.ReadLine();
  36.  
  37. }
  38. if (bookIsFound == false)
  39. {
  40. Console.WriteLine("The book you search is not here!");
  41. Console.WriteLine($"You checked{numberOfBooks} books.");
  42. }
  43. else
  44. {
  45. Console.WriteLine($"You checked{counter} books and found it.");
  46. }
  47.  
  48. }
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement