Conditionals and control flow exercise9


#1

instruction
1.
Set the canDrive variable equal to the ternary expression: (fuelLevel > 0) ? 'Y' : 'N';

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

	int fuelLevel = 3;

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

}

}

what's wrong?


#2

I'm having the same issue with 9. Ternary Conditional. I've even done Get Code which inserted the same code I already had in there and it's still throwing an error. If someone knows whats going on it would be great.


#3

the same error here.I’m stuck on that for like 2 weeks.
here’s the error that throws out when I run my code
"Did you set canDrive equal to the result of the ternary expression? You can use the example to help you."


#4
			int fuelLevel = 3;

	char canDrive = (fuelLevel > 0)? 'Y' : 'N';

	System.out.println(canDrive);

}

}

This is basically what i did. I just added a space in front of the question mark

char canDrive = (fuelLevel > 0) ? 'Y' : 'N';

And it fixed the error. lol