Advertisement
Guest User

Untitled

a guest
Nov 8th, 2019
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 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. while (n<x)
  10. {
  11. String newbook=scanner.nextLine();
  12. if(newbook.equals(book))
  13. {
  14. System.out.printf("You checked %d books and found it.",n);
  15. }
  16. n++;}
  17. System.out.printf("The book you search is not here!\n" +
  18. "You checked %d books.",x);
  19. }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement