您好,我對編碼相當(dāng)陌生,不明白我必須完成的所需任務(wù)。如何通過添加 main 方法來運(yùn)行以下代碼以確保其正常工作?答案和文件將非常有幫助,謝謝。public static boolean approxEqual (double x, double y){ //Judge where two numbers are close enough (equal) final double EPSILON = 1E-10; if (Math.abs(x-y)<EPSILON) { return(true); } return(false);}
1 回答

萬千封印
TA貢獻(xiàn)1891條經(jīng)驗(yàn) 獲得超3個贊
您可以聲明一個類并向其添加 main 方法,如下所示
public class Sol {
public static void main(String[] args) {
Sol.approxEqual(1.0,1.2)
}
public static boolean approxEqual (double x, double y)
{
//Judge where two numbers are close enough (equal)
final double EPSILON = 1E-10;
if (Math.abs(x-y)<EPSILON)
{
return(true);
}
return(false);
}
}
添加回答
舉報(bào)
0/150
提交
取消