-2

For some reason my keyboard will not input anything when prompted to do so. Here's my code:

import java.util.Scanner;

public class ForgetfulMachine {
    public static void main( String[] args) {
        Scanner keyboard = new Scanner(System.in);

        System.out.println( "What city is the capital of France?" );
        keyboard.next();

        System.out.println( "What is 6 multiplied by 7?");
        keyboard.nextInt();

        System.out.println( "Enter a number between 0.0 and 1.0");
        keyboard.nextDouble();

        System.out.println( "Is there anything else you would like to say?");
        keyboard.next();
    }
}
Sнаđошƒаӽ
  • 13,406
  • 11
  • 67
  • 83
HNO3
  • 1

1 Answers1

0

You need to store the value returned by next() into some variable, like so:

String input = keyboard.next();
// for int or float input, use appropriate variable type to store the input

// possibly print it to the console
System.out.println("You entered: " + input);
Sнаđошƒаӽ
  • 13,406
  • 11
  • 67
  • 83