+ 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

18th Jul 2019, 11:53 AM
Aaditya Thakur
Aaditya Thakur - avatar
9 Answers
+ 9
try to substitude nextDouble with nextDouble() Hope it helps
18th Jul 2019, 11:58 AM
Zhenis Otarbay
Zhenis Otarbay - avatar
+ 9
Aaditya Thakur I think you did not declare Scanner
18th Jul 2019, 12:02 PM
Zhenis Otarbay
Zhenis Otarbay - avatar
+ 9
Aaditya Thakur only one time after the System.out.println("Enter the star's bla bla bla:");
18th Jul 2019, 12:15 PM
Zhenis Otarbay
Zhenis Otarbay - avatar
+ 8
Aaditya Thakur try to declare Scanner before you use : Scanner myObj = newScanner(System.in);  // Create a Scanner object
18th Jul 2019, 12:13 PM
Zhenis Otarbay
Zhenis Otarbay - avatar
+ 1
Thanks I'll try
18th Jul 2019, 11:59 AM
Aaditya Thakur
Aaditya Thakur - avatar
+ 1
Doesn't work. Says cannot find symbol with an arrow pointing at the full stop before *Scanner*
18th Jul 2019, 12:01 PM
Aaditya Thakur
Aaditya Thakur - avatar
+ 1
Zhenis Otarbay Can you explain please. Thanks
18th Jul 2019, 12:04 PM
Aaditya Thakur
Aaditya Thakur - avatar
+ 1
Both times?
18th Jul 2019, 12:13 PM
Aaditya Thakur
Aaditya Thakur - avatar
+ 1
Thanks a lot
18th Jul 2019, 12:15 PM
Aaditya Thakur
Aaditya Thakur - avatar