Computer Science, asked by UniquePrincess1234, 6 months ago

write a program to compute and display the result of the expression in java:-
x^3 + 2 * 2 + x - 1​

Answers

Answered by swe15
1

Answer:

 Expected Output : 8 x 1 = 8 8 x 2 = 16 8 x 3 = 24 ... 8 x 10 = 80.

Answered by nikhilkumarsaha27
0

Explanation:

Relational operators are used to check conditions like whether two values are equal, or whether one is greater than the other. The following expressions show how they are used:

x == y // x is equal to y

x != y // x is not equal to y

x > y // x is greater than y

x < y // x is less than y

x >= y // x is greater than or equal to y

x <= y // x is less than or equal to y

The result of a relational operator is one of two special values, true or false. These values belong to the data type boolean; in fact, they are the only boolean values.

You are probably familiar with these operations, but notice that the Java operators are different from the mathematical symbols like =, ≠, and ≤. A common error is to use a single = instead of a double ==. Remember that = is the assignment operator, and == is a comparison operator. Also, there is no such thing as the =< or => operators.

The two sides of a relational operator have to be compatible. For example, the expression 5 < "6" is invalid because 5 is an int and "6" is a String. When comparing values of different numeric types, Java applies the same conversion rules we saw previously with the assignment operator. For example, when evaluating the expression 5 < 6.0, Java automatically converts the 5 to 5.0.

Most relational operators don’t work with strings. But confusingly, == and != do work with strings – they just don’t do what you expect. We’ll explain what they do later; in the meantime, don’t use them with strings. Instead, you should use the equals method:

String fruit1 = "Apple";

String fruit2 = "Orange";

System.out.println(fruit1.equals(fruit2));

The result of fruit1.equals(fruit2) is the boolean value false.

Similar questions