Ask your own question, for FREE!
Computer Science 15 Online
OpenStudy (a1234):

I'm supposed to find an error in this Java code...but I see none that affects what comes out of the code. Is it the parentheses on line 10?

OpenStudy (a1234):

public class Stuff { public static void main (String [] arguments) { int number = 100; System.out.println("I love the number " + number); System.out.println("Everyone loves the number."); number = number + 25; System.out.println("The number is now " + number); System.out.println("It is bigger."); System.out.println("It'll get smaller now."); number = (number - 100); System.out.println("It's now" + number); System.out.println("But everyone still likes it."); } }

OpenStudy (blazeryder):

In line 10 you can take away the (). They are unnecessary and I don't see the point in putting them there. There is also one little thing that I see, and that is in line 11. When I run the program I see there is no space between the string and the number. It shows: It's now25. So you need to add a space to the end of the string. Other than that I don't see a problem within the code. =)

OpenStudy (a1234):

The original code had the space in line 11...guess it was erased somewhere in translation. So the only error in there is in line 10. Thanks for the response!

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!