0
What is wrong with my code....plz help me
i have created a calculator....but it is npt working..help me.. https://code.sololearn.com/cIYG1mbUpk33/?ref=app
3 RĂ©ponses
+ 7
".nextInt() gets the next int, but doesn't read the new line character. This means that when you ask it to read the "next line", you read til the end of the new line character from the first time."
So this was what I did:
int a = s.nextInt();
int b = s.nextInt();
s.nextLine();
String c = s.nextLine();
input:
1
2
add
Output: 3
+ 3
input:
2 3 subtract
debug:
System.out.println(a);
System.out.println(b);
System.out.println(c);
output:
2
3
subtract // space at start
+ 1