9/11 Ternary Conditional help?!


#1

Hey, I am not too sure what i have done wrong with this code, So I have done the Instructions and I am getting the correct output value of 'Y' .

But I am getting an error message at the bottom of the screen 'Did you set canDrive equal to the result of the ternary expression? You can use the example to help you.' I have used the example and cant really work out what is going wrong... any assistance would be great :slight_smile:

Kindest regards

Lauren

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

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

	}
}

Help 9/11 ternary conditionals
#2

Hey there, what is the output error? can you post it here?
I think there's something wrong with the site, i'm coding too, but even if the code is correct i get an error and can't go forward.


#3

Hi, Yes think you are right, once I reset the code and wrote the exact same thing again it worked


#4

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