+ 1

Error: Bad operand '*' for binary . Why am I getting this

https://code.sololearn.com/cES5HZ9GJy5A/?ref=app

17th Nov 2021, 6:27 AM
Atulya Vaibhav Pandey
Atulya Vaibhav Pandey - avatar
7 Answers
+ 5
If you need to enter an integer value then use scanner.nextInt() and repeat Lesson 5.1. double result = 6.28 * scanner.nextInt();
17th Nov 2021, 6:40 AM
Solo
Solo - avatar
+ 4
Scanner is an object and you cannot multiply object with value Take user input using scanner object then multiply that input with pi.
17th Nov 2021, 6:31 AM
A͢J
A͢J - avatar
+ 4
A͢J - S͟o͟l͟o͟H͟e͟l͟p͟e͟r͟ but object names can also be considered variables am I right?
17th Nov 2021, 7:28 AM
Rishi
Rishi - avatar
+ 3
Atulya Vaibhav Pandey scanner is not a variable name it's an object of Scanner class. I think you need to learn again about variable and object. variable should have a type String, int, float or double.
17th Nov 2021, 6:44 AM
A͢J
A͢J - avatar
+ 3
Rishi Yes you can say but it would be a variables of non-primitive data type or user defined class. Here are some differences between object and variable https://www.sololearn.com/Discuss/416157/?ref=app
17th Nov 2021, 8:32 AM
A͢J
A͢J - avatar
+ 2
scanner is my variable name in which I am taking input. Right? A͢J - S͟o͟l͟o͟H͟e͟l͟p͟e͟r͟
17th Nov 2021, 6:40 AM
Atulya Vaibhav Pandey
Atulya Vaibhav Pandey - avatar