Spocoman

01. Old Books

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