+ 2
code not working [solved]
pls help my java code is not working . This is my first code in java and it's not working https://code.sololearn.com/c5dp5jZ4SH98/?ref=app
10 odpowiedzi
+ 5
Yash Arora🇮🇳 you're looking for something like this?
https://code.sololearn.com/cyyPz9XUknke/?ref=app
+ 5
Simple example
import java.util.Scanner;
public class TestScanner {
public static void main(String[] args) {
try ( Scanner scanner = new Scanner( System.in ) ) {
System.out.print( "Veuillez saisir un premier entier : " );
int a = scanner.nextInt();
System.out.print( "Veuillez saisir un second entier : " );
int b = scanner.nextInt();
int result = a + b;
System.out.printf( "La somme de %d et de %d vaut %d\n", a, b, result );
}
}
}
+ 2
Benjamin Jürgens like this:
Scanner a b=new Scanner(System.in);
+ 2
Simba thanks a lot
+ 1
Share your attempts please
+ 1
Use only one scanner. Input numbers on the same line, separated by a space
+ 1
HAMYD KHADDA thanks
0
Yash Arora🇮🇳 you are using double x= sc.nextInt():
But if you want to take integer value from keyboard/user then you have to take : int x =sc.nextInt()
- 2
D