Help!Ternary conditional!


#1

I don't know what's wrong with this code.I try many times.But it still inform me that "Did you set canDrive equal to the result of the ternary expression? You can use the example to help you." I'll appreciate it if you could help me to find the fault.Thanks a lot!!!
The following is my code:

int fuelLevel = 3;

	char canDrive =(fuelLevel > 0)? 'Y':'N';
	System.out.println(canDrive);

#2

You don't need the parenthesis around fuelLevel > 0, the rest of your code is correct, however.


#3

char canDrive = (fuelLevel > 0) ? 'Y' : 'N';
System.out.println(canDrive);

try giving space.


#4

Yes! The code was going on when I gave the space! Thanks for your help!


#5

It still doesn't work. Anyway, thanks for your help!


#6

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.