My input will be
12
4.0
has to be concatenated with this input
My Expected output is
16
8.0
RandomString has to be concatenated with this input
My code which tries to do this is follows
int i = 4;
double d = 4.0;
String s = "RandomString";
Scanner scan = new Scanner(System.in);
int j = scan.nextInt();
double e = scan.nextDouble();
String str = scan.nextLine();
int resInt = i + j; double resDouble = d + e; String resString = s +" "+ str;
System.out.println(resInt);
System.out.println(resDouble);
System.out.println(resString);
scan.close();
This behaves differently. As soon as I enter two lines of input it is giving me output. Not waiting for third line of my input. So now my output is
12
4.0
16
8.0
RandomString