Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class OldBooks {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String book = scanner.nextLine();
- int counter = 0;
- String input;
- 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