Computer Applications
Rewrite the following program segment using logical operators:
if(x > 5)
if(x > y)
System.out.println(x + y);
Java Operators
3 Likes
Answer
if ( x > 5 && x > y)
System.out.println(x+y);
Answered By
2 Likes
Related Questions
Give the output of the following:
int x = 2, y = 4, z = 1; int result = (++z) + y + (++x) + (z++);Give the output of the following:
int f = 10, m = 9; String e = (m % f == 9)? "YES": "NO"; System.out.print(e);Rewrite the following program segment using if-else statements instead of the ternary operator:
String grade = (marks>=90)?"A": (marks>=80)? "B": "C";
Rewrite the following program segment using if-else statements instead of the ternary operator:
commission = (sale > 5000) ? sale*10/100 : 0;