+ 2

what is wrong with String...?? when I input I don't get any given input why?? Can anyone explain me???

https://code.sololearn.com/cQ3GQULoRAf1

28th Feb 2022, 8:58 AM
Davinder Kumar
Davinder Kumar - avatar
8 Antworten
+ 3
If you use this: int a = Integer.parseInt(sc.nextLine()); double b = Double.parseDouble(sc.nextLine()); This is work
28th Feb 2022, 9:13 AM
Domonkos Gyömörey
Domonkos Gyömörey - avatar
+ 3
import java.util.*; public class Program { public static void main(String[] args) { // Sum of i and i1 , Sum of double d and d2 and Concatenate s and s2 int i = 4; double d = 4.0; String s = "hello"; Scanner sc=new Scanner(System.in); int i2 = Integer.parseInt(sc.nextLine()); double d2 = Double.parseDouble(sc.nextLine()); String s2 = sc.nextLine(); System.out.println( i + i2); System.out.println(d + d2); System.out.println(s +" "+ s2); } }
28th Feb 2022, 9:17 AM
Domonkos Gyömörey
Domonkos Gyömörey - avatar
+ 2
Just you need write input on more row 1row int 2row double 3row String
28th Feb 2022, 9:14 AM
Domonkos Gyömörey
Domonkos Gyömörey - avatar
+ 2
This is your code extension
28th Feb 2022, 9:17 AM
Domonkos Gyömörey
Domonkos Gyömörey - avatar
+ 2
Integer.parseInt() is parse a String with int format to Integer Double.parseDouble() is parse a String with double format(example 1.1) to double
28th Feb 2022, 9:18 AM
Domonkos Gyömörey
Domonkos Gyömörey - avatar
+ 1
Domonkos Gyömörey can you tell me how to use pareselnt i see this for the first time......👀
28th Feb 2022, 9:15 AM
Davinder Kumar
Davinder Kumar - avatar
+ 1
Domonkos Gyömörey Thanks you buddy today i learnt something new from you👍
28th Feb 2022, 9:22 AM
Davinder Kumar
Davinder Kumar - avatar
+ 1
I really like if people learn and get new experiments
28th Feb 2022, 9:24 AM
Domonkos Gyömörey
Domonkos Gyömörey - avatar