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 bookTitle = scanner.nextLine();
- int booksN = 0;
- String bookCounter = scanner.nextLine();
- boolean isFound = false;
- while(!bookCounter.equals("No More Books")){
- if(bookCounter.equals(bookTitle)){
- isFound=true;
- break;
- }
- bookCounter = scanner.nextLine();
- booksN++;
- }
- if (isFound){
- System.out.printf("You checked %d books and found it.",booksN);
- }else{
- System.out.printf("The book you search is not here!%nYou checked %d books.",booksN);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement