0

So in java, we use scanner because using this, we dont have to initialize in program, we can take inputs. Is that correct?

https://code.sololearn.com/cmvIus3z0t85/?ref=app This is not working.

9th Dec 2019, 7:05 PM
Ira Sarkar
Ira Sarkar - avatar
8 Respostas
+ 2
Yes the Scanner class is used to take user input and the variable which is going to hold a value assigned by the Scanner need not be initialized before hand. Because there is no point doing that.
9th Dec 2019, 7:20 PM
Avinesh
Avinesh - avatar
+ 1
You are taking both inputs in num1. Change the 2nd one to num2.
9th Dec 2019, 7:15 PM
Avinesh
Avinesh - avatar
+ 1
Your code is not working because you declare num1 twice. Line 9 should be: int num2 =... Also when printing the result, you are actually multiplying. To add the numbers put them in parentheses, otherwise they are just concatenated to the text: (num1 + num2)
9th Dec 2019, 7:15 PM
Tibor Santa
Tibor Santa - avatar
0
Oh yes
9th Dec 2019, 7:17 PM
Ira Sarkar
Ira Sarkar - avatar
0
I copy paste that, and forgot to correct😅😅
9th Dec 2019, 7:17 PM
Ira Sarkar
Ira Sarkar - avatar
0
And someone answer my question please.
9th Dec 2019, 7:18 PM
Ira Sarkar
Ira Sarkar - avatar
0
Ira Sarkar kindly change that num1 * num2 to num1+num2 and observe the result just like Tibor Santa mentioned.
9th Dec 2019, 7:23 PM
Avinesh
Avinesh - avatar