Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

missing method body, or declare abstract 1

Status
Not open for further replies.

baldockl

Programmer
Aug 28, 2002
1
AU
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;
}
}
}
 
Hi baldockl,

If you have a look at the end of your methodEquals() declaration line you'll see a semi-colon. Take it out and the program will work.

David
 
Hi David,

Thank you so much!

I really appreciate it!!!!

The program now works :)

Regards

Lee
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top