Conditionals exercise 9

Can’t figure out the problem here. I get this error (Did you set canDrive equal to the result of the ternary expression? You can use the example to help you.) when I put in this code.

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

    int fuelLevel = 3;

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



The code checker is happier on this one if you put spaces around each operator.

Thanks! Seemed like a silly error

1 Like