Guest User

edited

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