本帖最後由 王彥甯 於 2016-12-17 11:16 編輯
- public class JPA01 {
- public static void main(String args[]){
- double x;
- x = -3.2;
- System.out.printf("f(%.1f)=%.4f\n",x,f(x));
- x = -2.1;
- System.out.printf("f(%.1f)=%.4f\n",x,f(x));
- x = 0;
- System.out.printf("f(%.1f)=%.4f\n",x,f(x));
- x=2.1;
- System.out.printf("f(%.1f)=%.4f\n",x,f(x));
- }
- private static Object f(double x) {
- // TODO Auto-generated method stub
- return 3*(Math.pow(x, 3))+2*x-1;
- }
-
- }
複製代碼 |