Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String book = scanner.nextLine(), input;
- int counter = 0;
- while (!(input = scanner.nextLine()).equals("No More Books") && !input.equals(book)) {
- counter++;
- }
- if (input.equals(book)) {
- System.out.printf("You checked %d books and found it.\n", counter);
- } else {
- System.out.println("The book you search is not here!");
- System.out.printf("You checked %d books.\n", counter);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement