I was just re-reading my lecture scripts and trying out the code there. The problem is that the professor gave us only fragments of code and I really stuck on this one. I keep getting this error in Eclipse:
no main method
I still get the error even if I put public static void main(String[] args)
in the code. What should I change in it?
The main idea of this program is to calculate a square or square root.
public class MeineKlasse {
private String job;
private String getJob() {
return job;
}
public void setJob(String job) {
this.job = job;
System.out.println(job);
}
public double myMethode(double x) throws Exception {
if (job.equals("quadrat"))
return x * x;
if (job.equals("wurzel"))
return Math.sqrt(x);
System.out.println(myMethode(x) + "=");
throw new Exception("Fehler:Aufgabe nicht korrekt definiert");
}
}