2016-05-05 17 views
-2

何らかの理由でキーボードが何か入力を求められたときに何も入力しません。keyboard.next入力を受け取っていません

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(); 
    } 
} 
+0

コンソールを書くために何をしようとしていますか? – Tom

+1

'keyboard.next()によって返された値を使用していません。 –

+1

あなたが入力している値を取得しようとしていますか?あなたのコードが何かを受け入れるので、ちょうど –

答えて

0

あなたは、いくつかの変数にnext()によって返された値を格納する必要があり、そのような:ここに私のコードは

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); 
関連する問題