Guest User

Untitled

a guest
Dec 14th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. Scanner sc = new Scanner(file);
  2.  
  3. while (sc.hasNextLine()) {
  4. String line = sc.nextLine();
  5. System.out.println(line);
  6. //Find the largest and smallest numbers in the file
  7.  
  8. double largest = sc.nextDouble();
  9. double smallest = sc.nextDouble();
  10.  
  11. while (sc.hasNextDouble()) {
  12. double number = sc.nextDouble();
  13. if ( number < largest ) {
  14. largest = number;
  15. while(sc.hasNextDouble()) {
  16. if (number > smallest)
  17. smallest = number;
  18.  
  19. "Exception in thread "main" java.util.NoSuchElementException
  20. at java.util.Scanner.throwFor(Scanner.java:862)
  21. at java.util.Scanner.next(Scanner.java:1485)
  22. at java.util.Scanner.nextDouble(Scanner.java:2413)
  23. at Numbers3.main(Numbers3.java:24)".
Add Comment
Please, Sign In to add comment