Value of variable 2#8826

Value of variable 2 (Editorial)

Algorithm Analysis

To solve the problem, it is necessary to calculate the value of the given expression.

Algorithm Implementation

Read the value of variable .

scanf("%lf", &x);

Calculate the value of variable .

y = x - (x * x + 4) / 2 + x * x * x - 3 / (x + 7);

Print the result to three decimal places.

printf("%.3lf\n", y);

Java Implementation

import java.util.*;

class Main
{
    public static void main(String[] args)
    {
        Scanner con = new Scanner(System.in);
        double x = con.nextDouble();
        double y = x - (x * x + 4) / 2 + x * x * x - 3 / (x + 7);
        System.out.print(y);
        con.close();
    }
}

Python Implementation

x = float(input())
y = x - (x * x + 4) / 2 + x * x * x - 3 / (x + 7)
print(y)