Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class OldBooks_01 {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String searchedBook = scanner.nextLine();
- //1. ако открием книгата 2. ако получим команда "No book...."
- //команда -> no more books или заглавие на книга
- int countCheckedBooks = 0;
- while (true) {
- //команда -> заглавие
- String command = scanner.nextLine();
- if (command.equals("No More Books")) {
- System.out.println("The book you search is not here!");
- System.out.printf("You checked %d books.", countCheckedBooks);
- break;
- } else if (command.equals(searchedBook)) {
- //намираме книгата
- System.out.printf("You checked %d books and found it.", countCheckedBooks);
- break;
- } else {
- countCheckedBooks++;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement