logo Practice-It logo

BJP4 Self-Check 5.24: scannerValues

Language/Type: Java input Scanner
Author: Marty Stepp (on 2016/09/08)

Consider the following code:

Scanner console = new Scanner(System.in);
System.out.print("Type something for me! ");
if (console.hasNextInt()) {
    int number = console.nextInt();
    System.out.println("Your IQ is " + number);
} else if (console.hasNext()) {
    String token = console.next();
    System.out.println("Your name is " + token);
}

What is the output when the user types the following values? (You don't need to include the "Type something for me!" prompt or the user's input; just write the line of output that would appear after the user is done typing and presses Enter.)

Jane
56
56.2

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.