aspose file tools*
The moose likes Java in General and the fly likes Regarding ternary operator Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Regarding ternary operator" Watch "Regarding ternary operator" New topic
Author

Regarding ternary operator

Saral Saxena
Ranch Hand

Joined: Apr 22, 2011
Posts: 202

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

Joined: Nov 20, 2011
Posts: 144

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


MySQL Blog
http://mysqlearner.blogspot.com/
Saral Saxena
Ranch Hand

Joined: Apr 22, 2011
Posts: 202

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

Joined: Jan 10, 2002
Posts: 60049
    
  65

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Regarding ternary operator
 
Similar Threads
can any one explain this
A curious problem on Short Circuit & and ternary operator.
Advantage of Ternary operator ?
conditional operators and jQuery
Ternary operator with if/elseif/else