logo Practice-It logo

BJP5 Self-Check 6.14: readme3nextIntDouble

Language/Type: Java file processing mystery Scanner
Author: Jared Jones (on 2019/09/19)

Consider a file called readme.txt that has the following contents:

6.7     This file has
        several input lines.

  10 20         30   40


What would be the output from the code in the previous exercise (shown below) if the calls to hasNext and next were replaced by calls to hasNextInt and nextInt, respectively? How about hasNextDouble and nextDouble ?

Scanner input = new Scanner(new File("readme.txt"));
int count = 0;
while (input.hasNext()) {
    System.out.println("input: " + input.next());
System.out.println(count + " total");

You must log in before you can solve this problem.

Log In

If you do not understand how to solve a problem or why your solution doesn't work, please contact your TA or instructor.
If something seems wrong with the site (errors, slow performance, incorrect problems/tests, etc.), please

Is there a problem? Contact a site administrator.