Advertisement
Rayk

Untitled

Apr 27th, 2020
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Main {
  6. public static void main(String[] args) {
  7. Scanner scanner = new Scanner(System.in);
  8.  
  9. String correctBook = scanner.nextLine();
  10. String inputBook = scanner.nextLine();
  11.  
  12. int attempts = 1;
  13. while (!inputBook.equals(correctBook)) {
  14. attempts += 1;
  15. inputBook = scanner.nextLine();
  16. }
  17.  
  18. System.out.printf("Book found! Attempts: %d", attempts);
  19. }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement