Generalisations in "Conditionals and Control Flow"


#1

With this excercise here:

if(2015 < 2016) {

		System.out.println("Stuck in the past...");

	}else {

		System.out.println("Upgraded to the future!");

I am confused on what text to place in the 'else' bar. I thought that if the initial statement was true, the if block would print, but if it was not true, the else block would print. Why do I need to place text in the else bar and what should I place in there to solve the question?

Thanks in advance


#2

That is correct.

You aren't being asked to change anything in the else block. You are being asked to change the initial condition to something false so that the else block will print its message.

Do you see what they are getting at now?


#3

Now i got this 2! Thanks for the tip!


#4

I have tried using different conditions such as (2 < 1) and (!true) but these do not seem to work. Is there another type of condition I am needing as I thought the two I listed were boolean, as they returned a true or false answer. Thanks


#5

They look like they should work. Did you change anything else that might be affecting the code?


#6

I have restarted the excercise from scratch and tried to solve it from the code given with no luck.


#7

Could you post a screen shot of your exercise, the whole web page would be great so that I can see everything that you are seeing.


#8

I am currently on my tablet so sorry if the image is a little cramped. I can provide a full size one in around 1hr. It is question 2 that i am having trouble with. Thanks.


#9

I get an error message when I try to run that code with this line uncommented:

( 3 >= 3 && !(true || true) )

Do you get that too?


#10

A missing "if" perhaps @albionsrefuge. Genuine curiosity as I have no actual experience in Java


#11

A good thought, but not this time. The if is where it should be.


#12

That line answers q1 of the exercise and is what appears when i totally reset it. I also dont think that it affects the second question, however it does continue to show an error for that line. In fact, a lot of errors show whenever I run the script from default, so it might be some formatting issue.


That is a full size screenshot if it helps.

Thanks


#13

Put the // back on line 4. That should clear up the errors in the output pane.


#14

Yes, line 4 didnt need to be changed at all. but also im wondering if you had the problem where the run button keeps spinning, because its happening to me, and i cant continue.


#15

I'm not having that problem, but lots of people are.having it in various exercises. I don't know what the problem is but Codecademy staff are aware and are working on it.


#16

So I replaced the // on line 4 and it removed an error, however the subway train line was still showing an error. I input the correct number to answer q3 and both q2 and 3 were solved. Thank you so much for all the support with the course.


#17

put // on line 4 and 5


#18