Hi,
I am a programming newbie - learning Java.
I am having a problem with the following tiny program.
Any help would be greatly appreciated.
On attempting to compile I am getting three errors and I'm stumped.
D:\Central\Grad_Dip_Comp\ST501\ST151\P05>javac tolerance.java
tolerance.java:27: missing method body, or declare abstract
public static boolean methodEquals(double first, double second, double tol);
^
tolerance.java:34: return outside method
return true;
^
tolerance.java:38: return outside method
return false;
^
3 errors
Thankyou for your time and regards to you
Lee
=======================================
import io.*;
public class tolerance
{
public static void main(String [] args)
{
double firstValue, secondValue, tolerance;
boolean areequals;
firstValue=ConsoleInput.readDouble ("Input first value:"
secondValue=ConsoleInput.readDouble ("Input second value:"
tolerance=ConsoleInput.readDouble ("Input tolerance:"
areequals=methodEquals(firstValue, secondValue, tolerance);
if (areequals == true)
{
System.out.println("The numbers are equal"
}
else
{
System.out.println("The numbers are not equal"
}
}
public static boolean methodEquals(double first, double second, double tol);
{
double first, second, tol;
if (Math.abs(first-second)<tol)
{
return true;
}
else
{
return false;
}
}
}
I am a programming newbie - learning Java.
I am having a problem with the following tiny program.
Any help would be greatly appreciated.
On attempting to compile I am getting three errors and I'm stumped.
D:\Central\Grad_Dip_Comp\ST501\ST151\P05>javac tolerance.java
tolerance.java:27: missing method body, or declare abstract
public static boolean methodEquals(double first, double second, double tol);
^
tolerance.java:34: return outside method
return true;
^
tolerance.java:38: return outside method
return false;
^
3 errors
Thankyou for your time and regards to you
Lee
=======================================
import io.*;
public class tolerance
{
public static void main(String [] args)
{
double firstValue, secondValue, tolerance;
boolean areequals;
firstValue=ConsoleInput.readDouble ("Input first value:"
secondValue=ConsoleInput.readDouble ("Input second value:"
tolerance=ConsoleInput.readDouble ("Input tolerance:"
areequals=methodEquals(firstValue, secondValue, tolerance);
if (areequals == true)
{
System.out.println("The numbers are equal"
}
else
{
System.out.println("The numbers are not equal"
}
}
public static boolean methodEquals(double first, double second, double tol);
{
double first, second, tol;
if (Math.abs(first-second)<tol)
{
return true;
}
else
{
return false;
}
}
}