Advertisement
Guest User

Untitled

a guest
Nov 8th, 2019
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class library {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6. String book = scanner.nextLine();
  7. int n = 0;
  8. int x = Integer.parseInt(scanner.nextLine());
  9. boolean isfound = false;
  10. while (n <= x) {
  11. String newbook = scanner.nextLine();
  12. if (newbook.equals(book)) {
  13. System.out.printf("You checked %d books and found it.", n);
  14. isfound = true;
  15. break;
  16. }
  17. n++;
  18. }
  19. if (!isfound) {
  20. System.out.printf("The book you search is not here!\n" +
  21. "You checked %d books.", x);
  22. }
  23. }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement