osx - How do I get console input for a java program in Terminal on Mac? -
i'm trying create simple program converts degrees in fahrenheit degrees in celcius on mac through terminal application , using vi editor.
my code follows:
import java.io.*; public class mythirdjavaprogram { public static void main (string [] args) { double celcius, fahrenheit; fahrenheit = console.readdouble("fahrenheit"); celcius = convertfahrenheittocelcius(fahrenheit); system.out.println("degrees in celcius " + celcius); } private static double convertfahrenheittocelcius (double ins) { double celcius; celcius = ((ins-32.0)*5.0)/9.0; return celcius; } } the error keep getting is:
mythirdjavaprogram.java:7: cannot find symbol symbol : method readdouble(java.lang.string) location: class java.io.console fahrenheit = console.readdouble("fahrenheit"); ^ what doing wrong here? i've tried lot of different ways code such as
fahrenheit = console.in.readdouble(fahrenheit) and
fahrenheit = system.console.readdouble(fahrenheit) but absolutely nothing works , error statement same every time. i'm new java confusing heck out of me. solves dang thing awesome, if tell me re-write half of it.
there no method readdouble(string) in console api. please use java.util.scanner. example scanner.nextdouble()
Comments
Post a Comment