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 favoriteBook = scanner.nextLine();
- String book = scanner.nextLine();
- Integer counter = 0;
- while (!"No More Books".equals(book)){
- if(!book.equals(favoriteBook)){
- book = scanner.nextLine();
- counter +=1;
- }else{
- System.out.printf("You checked %d books and found it.",counter);
- break;
- }
- }
- if(!book.equals(favoriteBook)){
- System.out.println("The book you search is not here!");
- System.out.printf("You checked %d books.",counter);
- }else{}
- }
- }
Add Comment
Please, Sign In to add comment