Exercise 9: Ternary (Java)

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>

<In what way does your code behave incorrectly? Include ALL error messages.>
It says this is wrong when it’s clearly not:

``` public class Ternary { public static void main(String[] args) {
    int fuelLevel = 3;

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

}

}

<do not remove the three backticks above>

Hi I think that you should save (fuelLevel > 1) ? β€˜Y’ : β€˜N’; inside the vriable canDrive

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

Thanks :slight_smile:

1 Like

As I looked at the code the instruction says β€œSet the canDrive variable equal to the ternary expression: (fuelLevel > 0) ? β€˜Y’ : β€˜N’;” My issue was I set fuelLevel > 1 not 0. Hope this helps