Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Regarding ternary operator

 
Saral Saxena
Ranch Hand
Posts: 203
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi folks,

Please guide me how to write the ternary operator( ?) for this nested loop....

class IfElseDemo {
public static void main(String[] args) {

int testscore = 76;
char grade;

if (testscore >= 90) {
grade = 'A';
} else if (testscore >= 80) {
grade = 'B';
} else if (testscore >= 70) {
grade = 'C';
} else if (testscore >= 60) {
grade = 'D';
} else {
grade = 'F';
}
System.out.println("Grade = " + grade);
}
}

How will ternary operator would be wriiten for this..?
 
Zeeshan Sheikh
Ranch Hand
Posts: 144
Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anyone can provide you the solution but its not going to help you. You have to atleast try to write it and if there are any issues Please post here for help. Anyways I will point you in the right direction

What is a Tenary Operator
 
Saral Saxena
Ranch Hand
Posts: 203
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Zeeshan Sheikh wrote:Anyone can provide you the solution but its not going to help you. You have to atleast try to write it and if there are any issues Please post here for help. Anyways I will point you in the right direction

What is a Tenary Operator


Hi,

I need the solution to enhance my understanding..!!
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64688
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to ShowSomeEffort. What's your best shot at it?

P.S. There's no "loop" at all in your code, let alone a "nested loop". An if statement is not a loop.
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please BeForthrightWhenCrossPostingToOtherSites.(⇐click)
https://forums.oracle.com/forums/thread.jspa?threadID=2364445&tstart=0


[EDIT] While the advice for courtesy still applies, it was a different thread that was crossposted. The subjectline messed me up. Sorry for any confusion.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic