0

Stuck on java operators.

Hi guys, I need a little help. What was my mistake? "Bad operand type for binary operator *" error. import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); double pi = 3.14; //your code double rad = scanner * 2 * pi; System.out.println(rad); } }

18th Nov 2020, 12:34 PM
ŠšŠøŠ±ŠµŃ€ Š‘Š¾Š±Ń‘Ń€
3 Answers
+ 1
To get a double value from the user, you should use scanner.nextDouble() instead of scanner. https://www.sololearn.com/learn/Java/2220/
18th Nov 2020, 12:38 PM
ä½ ēŸ„é“č¦å‰‡ļ¼Œęˆ‘也ę˜Æ
ä½ ēŸ„é“č¦å‰‡ļ¼Œęˆ‘也ę˜Æ - avatar
0
Now I understand. Thank you for your help, big brother.
18th Nov 2020, 12:44 PM
ŠšŠøŠ±ŠµŃ€ Š‘Š¾Š±Ń‘Ń€
0
Java has Math.PI
18th Nov 2020, 12:57 PM
zemiak