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
132 Likes
Answer
String grade;
if (marks >= 90)
grade = "A";
else if (marks >= 80)
grade = "B";
else
grade = "C";
Answered By
81 Likes
Related Questions
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 logical operators:
if(x > 5) if(x > y) System.out.println(x + y);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