Maybe I’m forgetting an import at the head, but nothing seems to work. I’m trying to learn java and still beginner.
public class Main {
public static void main(String[] args) {
String s1=getInput("Enter First Number") ;
String s2=getInput("Enter second Number");
double d1=Double.parseDouble(s1);
double d2=Double.parseDouble(s2);
double result=d1+d2 ;
System.out.println(result);
}}
results in an error because the compiler doesn’t recognize getInput("");
This is from Eclipse:
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
The method getInput(String) is undefined for the type Main
The method getInput(String) is undefined for the type Main
at Main.main(Main.java:8)
You’re calling a getInput()-method which doesn’t exist in your class. Have a look at this Java tutorial on I/O:
http://docs.oracle.com/javase/tutorial/essential/io/cl.html