What's up with this if code?
System.out.println("Example2c: ");
int A = 85;
int B = 65;
String out = "\tNot a valid input!";
if (x > A) out = "\tWell done!";
if (x > B) out = "\tOK!";
if (x > 0) out = "\tNot good!";
System.out.println(out);
I input 90 and it print out "Not good". Wth? 90>85, 90>65, 90>0 so shouldn't it print out all the of them except not a valid input?
Re: What's up with this if code?
Hey! First of all, I'd like to recommend you take a step back and look at what you've written so far. Get a pen and paper and write out exactly what each thing does. Also, I recommend looking at The if-then and if-then-else Statements (The Java™ Tutorials > Learning the Java Language > Language Basics) and really understand the syntax for the "if" statements.