Advertisement
MARINA_GREBENAROVA

Old_Books

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