您好,我對編碼相當陌生,不明白我必須完成的所需任務。如何通過添加 main 方法來運行以下代碼以確保其正常工作?答案和文件將非常有幫助,謝謝。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貢獻1891條經驗 獲得超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);
}
}
添加回答
舉報
0/150
提交
取消