Advertisement
sanyakasarova

01. Old Books

Jun 6th, 2021
306
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _03.OddEvenPosition
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. string favoriteBook = Console.ReadLine();
  10.  
  11. int bookCounter = 0;
  12.  
  13. string currentBook = Console.ReadLine();
  14.  
  15. while (currentBook != "No More Books")
  16. {
  17. if (currentBook == favoriteBook)
  18. {
  19. Console.WriteLine($"You checked {bookCounter} books and found it.");
  20. break;
  21. }
  22.  
  23. bookCounter++;
  24.  
  25. currentBook = Console.ReadLine();
  26. }
  27.  
  28. if (currentBook == "No More Books")
  29. {
  30. Console.WriteLine("The book you search is not here!");
  31. Console.WriteLine($"You checked {bookCounter} books.");
  32. }
  33.  
  34.  
  35. }
  36. }
  37. }
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement