import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("x의 값을 입력하세요 : ");
double x = scanner.nextDouble();
scanner.close();
Absolute absolute = new Absolute(x);
absolute.mtd_Abs();
}
}
public class Absolute {
private double x;
public Absolute(double x) {
this.x = x;
};
public void mtd_Abs() {
//2곱하기 x의 3제곱 표기 : 2*x^3
double res = 2 * Math.pow(this.x, 3) + 3 * Math.pow(this.x, 2) + 4;
res = Math.abs(res);
System.out.printf("res : %.2f", res);
}
}
📌 Math.abs(); : 절대값 반환