It looks like you're using an Ad Blocker.

Please white-list or disable AboveTopSecret.com in your ad-blocking tool.

Thank you.

 

Some features of ATS will be disabled while you continue to use an ad-blocker.

 

compiler wont work, i need a lil help

page: 1
0

log in

join
share:

posted on Feb, 13 2006 @ 09:02 PM
link   
hey, im having a little trouble with my compiler and need a little help determining the output of a program. I need to determine the output for the following code sets when x is 9 and y is 11, and when x is 11 and y is 9. I tried to figure it out on paper but im new to java and struggling a bit.

heres the code:



if (x < 10 )
if (y > 10)
System.out.println( "*****" );
else
System.out.println( "#####" );
System.out.println( "$$$$$");





if (x < 10 )
[
if (y > 10)
System.out.println( "*****" );
]
else
[
System.out.println( "#####" );
System.out.println( "$$$$$");
]



posted on Feb, 13 2006 @ 11:16 PM
link   
What problems are you having with the compiler? Is it throwing a syntax error of some kind, or is it not able to find a particular file, or...?



posted on Feb, 14 2006 @ 12:26 AM
link   
I'm with MCory... You should give a bit more info. What is the error message(s) displayed and what is the piece of code supposed to do? Also posting a bit more code can be helpful - try posting the whole class/file if it's not too long.



posted on Feb, 14 2006 @ 09:32 AM
link   
I think the obvious lesson of this code is that the "if" and "else" commands only control one line after test unless you put brackets around multiple commands. Other than that do you really want me to give you the output? You won't learn anything if I do, plus I've already just pointed out the core of this lesson.


For Example:



if(some test = true)
This line is executed if the test is true;
This line is executed no matter what.


if(some test = true)
[
this line is executed if the test is true;
this line also is executed only if the test is true;
]




new topics

top topics
 
0

log in

join