Advertisement
Spocoman

Old Books

Oct 13th, 2023
613
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.93 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 bookCount = int.Parse(Console.ReadLine());
  11.             string command = Console.ReadLine();
  12.             int counter = 0;
  13.  
  14.             for (int i = 0; i < bookCount && command != ""; i++)
  15.             {
  16.                 if (command == "No More Books" || command == book)
  17.                 {
  18.                     break;
  19.                 }
  20.                 counter++;
  21.                 command = Console.ReadLine();
  22.             }
  23.  
  24.             if (command == book)
  25.             {
  26.                 Console.WriteLine($"You checked {counter} books and found it.");
  27.             }
  28.             else
  29.             {
  30.                 Console.WriteLine("The book you search is not here!");
  31.                 Console.WriteLine($"You checked {counter} books.");
  32.             }
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement