import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
public static void main(String[] args) {
int i = 4;
double d = 4.0;
String s = "hello ";
Scanner scan = new Scanner(System.in);
int a;
double b;
String c;
/* Read and save an integer, double, and String to your variables.*/
a = scan.nextInt();
b = scan.nextDouble();
c= scan.nextLine();
/* Print the sum of both integer variables on a new line. */
System.out.println(i+a);
/* Print the sum of the double variables on a new line. */
System.out.println(b+d);
/* Concatenate and print the String variables on a new line;
the 's' variable above should be printed first. */
System.out.println(s+c);
scan.close();
}
}
をスキャンオプションを使用している間、完全な文字列を読み取ることができません!これは私の最初のJavaプログラムです私は 4.0 世界として入力を与えたときにJavaで
このコードで使用されているscan.nextLine()はstringの値を読みません。唯一のスペースまで読み 私も(scan.nextを使用してみました)(すなわち、1つの単語だけ)
あなたは何を意味するのか分かりません。私のためにうまく動作します。 '8'、' 8.0'と 'hello World! 'を表示します。 –
あなたの質問は何ですか?それはちょうどあまりにも曖昧です – codemirel
Robby Cornelissen私は8、8.0とhello Worldとして出力をしたい!これは、Javaで私の最初のプログラムではない8、8.0とこんにちは世界!私の問題は、scan.next()が文字列全体を読み取っていないことと、scan.nextLine()が1つの単語も読み取っていないことです。 –