+ 1
help please
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 goes here double result = 2*pi; double result1 = result*scanner; System.out.println(result1); } } /usercode/Main.java:10: error: bad operand types for binary operator '*' double result1 = result*scanner; ^ first type: double second type: Scanner 1 error
3 Antworten
+ 6
replace the last "scanner" with "scanner.nextDouble()”
+ 4
Влад Маслов
scanner is a class object and result is a value of type double so you cannot mulitply classobject with value because of different types. This is basic concepts which should be clear.
We create object to access methods of class so here Scanner is a class and scanner is an object. Using this object we can access nextInt(), nextDouble (), nextLine() methods.