-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBookshelve.java
More file actions
25 lines (23 loc) · 854 Bytes
/
Copy pathBookshelve.java
File metadata and controls
25 lines (23 loc) · 854 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import java.util.Scanner;
public class Bookshelve {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String bookName = scanner.next();
bookName += scanner.nextLine();
String currentBook = scanner.next();
currentBook += scanner.nextLine();
int countBook = 0;
while(!currentBook.equals("No More Books")){
if(currentBook.equals(bookName)){
System.out.printf("You checked %d books and found it.",countBook);
break;
}
countBook ++;
currentBook = scanner.next();
currentBook += scanner.nextLine();
}
if(currentBook.equals("No More Books")){
System.out.printf("The book you search is not here!%nYou checked %d books.",countBook);
}
}
}