Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace The_Old_Library
- {
- class Program
- {
- static void Main(string[] args)
- {
- string favouriteBook = Console.ReadLine();
- int capacity = int.Parse(Console.ReadLine());
- int counter = 0;
- bool isBookFound = false;
- string input = Console.ReadLine();
- while (counter < capacity)
- {
- if (input == favouriteBook)
- {
- isBookFound = true;
- break;
- }
- counter++;
- input = Console.ReadLine();
- }
- if (isBookFound)
- {
- Console.WriteLine($"You checked {counter} books and found it. ");
- }
- else
- {
- Console.WriteLine("The book you search is not here!");
- Console.WriteLine($"You checked {capacity} books.");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment