Computer Applications
Rewrite the following program segment using if-else statements instead of the ternary operator:
String grade = (marks>=90)?"A": (marks>=80)? "B": "C";
Java
Java Operators
ICSE 2014
115 Likes
Answer
String grade;
if (marks >= 90)
grade = "A";
else if (marks >= 80)
grade = "B";
else
grade = "C";
Answered By
70 Likes
Related Questions
What is the value of y after the execution?
y+= ++y + y-- + --y; when int y=8Give the output of the following expression:
a+= a++ + ++a + --a + a--; when a = 7;Rewrite the following program segment using if-else statements instead of the ternary operator:
commission = (sale > 5000) ? sale*10/100 : 0;
Rewrite the following program segment using if-else statements instead of the ternary operator:
net = (salary > 10000) ? salary - (8.33/100)*salary : salary - (5/100)*salary