.9 Ternary Conditional


#1

Can anyone help me with this?


#2

Can anyone help me with this?

Edit:
Hi @erkokoer, It wants (fuelLevel > 0) you have
entered (fuelLevel > 1) in the source code.


#3

@kodeman89
Hello, I have entered (fuelLevel >0) but also it pops an error saying

"Did you set canDrive equal to the result of the ternary expression?"

Please help me out,how to fix this issue?


#4

@prashanthre1 Your code looks good, it just while doing these lessons
we have to be extra careful to watch all punctuation. Please try capitalizing
you're Y and N and let me know if that fixes you're problem, thanks!


#5

as @kodeman89 has pointed out take a a good look at the char value they expect you to print out

'Y' : 'N'
//but you have
'y' : 'n'

when they test your code, they check for those values exactly


#6


tiene las letras en mayusculas y aun asi no corre Somebody help me ;(


#7

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

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

/* I'm still getting error and not able to complete the exercise not sure what is wrong */
}
}


#8

Ok, I solved it.

Note sure what the actual issue is but I Just copied the code line from the instructions pane and pasted in on to the complier and it worked. not clear as to the reason because my code was exactly the same as what they had given


#9

I too did the exact instructions. I found that after placing a space in between a few and kept clicking run it worked!!
public class Ternary {
public static void main(String[] args) {

		int fuelLevel = 3;

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

	}
}

#11

It requires in every term, before 'Y', ':', 'N' ';'
Use Space


#12

use space only it working on me


#13