解题思路:
注意事项:
参考代码:
import java.util.Scanner; public class Main{ public static void main(String arg[]){ Scanner sc=new Scanner(System.in); double x=sc.nextDouble(); if(x<0) output_function(Absolute_value_function(x)); else if(x>=0&&x<2) output_function(Square_root_function(x)); else if(x>=2&&x<4) output_function(Exponential_function(x)); else output_function(First_order_function(x)); } public static double Absolute_value_function(double x) { return Math.abs(x); } public static double Square_root_function(double x) { double y=x+1; return Math.sqrt(y); } public static double Exponential_function(double x) { double y=x+5; return Math.pow(y,5); } public static double First_order_function(double x) { return 2*x+5; } public static void output_function(double x) { System.out.printf("%.2f", x); } }
0.0分
0 人评分