Java: Find the value of specified expression
Evaluate Expressions
Write a Java program to find the value of a specified expression.
a) 101 + 0) / 3
b) 3.0e-6 * 10000000.1
c) true && true
d) false && true
e) (false && false) || (true && true)
f) (false || false) && (true && true)
Sample Solution:
Java Code:
Sample Output:
(101 + 0) / 3)-> 33 (3.0e-6 * 10000000.1)-> 30.0000003 (true && true)-> true (false && true)-> false ((false && false) || (true && true))-> true (false || false) && (true && true)-> false
Flowchart:

For more Practice: Solve these Related Problems:
- Write a Java program to evaluate a complex expression mixing arithmetic, bitwise, and logical operators without using extra parentheses.
- Write a Java program to compute the value of an expression that combines integer division, modulus, and floating-point multiplication in one statement.
- Write a Java program to evaluate a nested ternary expression that includes relational and bit-shift operations.
- Write a Java program to test Java operator precedence by evaluating an expression containing arithmetic, relational, and logical operators.
Java Code Editor:
Contribute your code and comments through Disqus.
Previous: Write a Java program to test if a binary tree is a subtree of another binary tree.
Next: Write a Java program that accepts four integer from the user and prints equal if all four are equal, and not equal otherwise.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics