Advertisement
knikolov98

Untitled

Sep 25th, 2019
119
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 UprWhile
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             string bookWanted = Console.ReadLine();
  10.             string bookInput = string.Empty;
  11.             int numBooks = int.Parse(Console.ReadLine());
  12.             int counter = 0;
  13.  
  14.  
  15.             bookInput = Console.ReadLine();
  16.  
  17.             while (counter < numBooks)
  18.             {
  19.  
  20.                 if (bookInput == bookWanted)
  21.                 {
  22.                     break;
  23.                 }
  24.  
  25.                 else
  26.                 {
  27.                     bookInput = Console.ReadLine();
  28.                 }
  29.                 counter++;
  30.             }
  31.  
  32.             if (counter < numBooks)
  33.                 Console.WriteLine($"You checked {counter} books and found it.");
  34.  
  35.             else
  36.             {
  37.                 Console.WriteLine($"The book you search is not here!");
  38.                 Console.WriteLine($"You checked {counter} books.");
  39.  
  40.             }
  41.  
  42.         }
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement