alexbancheva

The Old Library

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