+ 1
Can anyone find an error?
import java.lang.Math; import java.util.Scanner; public class Program { public static void main(String[] args) { System.out.println("Enter the star's apparent magnitude:"); double mag=Scanner.nextDouble; System.out.println("Enter the distance in light years:"); double r=Scanner.nextDouble; double dis= r/3.26; double aMag= 5*(Math.log10(dis/10)+mag); System.out.println(aMag); } } It says some error in the nextdouble command. I'm very new to it so pls help
9 Réponses
+ 9
try to substitude nextDouble with nextDouble()
Hope it helps
+ 9
Aaditya Thakur I think you did not declare Scanner
+ 9
Aaditya Thakur only one time after the System.out.println("Enter the star's bla bla bla:");
+ 8
Aaditya Thakur try to declare Scanner before you use : Scanner myObj = newScanner(System.in); // Create a Scanner object
+ 1
Thanks I'll try
+ 1
Doesn't work. Says cannot find symbol with an arrow pointing at the full stop before *Scanner*
+ 1
Zhenis Otarbay Can you explain please. Thanks
+ 1
Both times?
+ 1
Thanks a lot