Magic Numbers last training point: Stuck despite seemingly correct code

Hey, fellas!

I worked through the additional last training of that subchapter and after fixing the “all” variable - which to that point unfortunately wasn’t teached - my code looks exactly like the one in the hin section. but I get a bunch of errors anyway.

Here is my code:
“public class Magic {
public static void main(String args) {
int myNumber = 123;
int magicNumber = myNumber * myNumber;
int magicNumber += myNumber;
int magicNumber /= myNumber;
all += 17;
int magicNumber -= myNumber;
int magicNumber /= 6;
System.out.println(magicNumber);”

And my errors:
“Magic.java:5: error: ‘;’ expected
int magicNumber += myNumber;
^
Magic.java:5: error: not a statement
int magicNumber += myNumber;
^
Magic.java:6: error: ‘;’ expected
int magicNumber /= myNumber;
^
Magic.java:6: error: not a statement
int magicNumber /= myNumber;
^
Magic.java:8: error: ‘;’ expected
int magicNumber -= myNumber;
^
Magic.java:8: error: not a statement
int magicNumber -= myNumber;
^
Magic.java:9: error: ‘;’ expected
int magicNumber /= 6;
^
Magic.java:10: error: reached end of file while parsing
System.out.println(magicNumber);
^
8 errors”

I don’t see where there should be errors where it is pointed out.

Would appreciate if somebody could get me a hint.

https://www.codecademy.com/courses/learn-java/projects/math-magic

Not sure if this is causing this specific issue, but you don’t want to declare the same variable multiple times using the int keyword. You only do it for the first instance of the variable. I’m also curious what all is in the line all += 17, seems like this has not been declared before this! Have a look into those two things and see if that helps.

1 Like

Ohhh gosh! Yeah, sure! Was definitely sleeping time as I already napped in before that task xD Totally oversaw that. We’ll, now I’m only stuck at “all”.

“public class Magic {
public static void main(String args) {
int myNumber = 123;
int magicNumber = myNumber * myNumber;
magicNumber += myNumber;
magicNumber /= myNumber;
all += 17;
magicNumber -= myNumber;
magicNumber /= 6;
System.out.println(magicNumber);
}
}”

And my error:
“Magic.java:7: error: cannot find symbol
all += 17;
^
symbol: variable all
location: class Magic
1 error”

Well, I just tried it with magicNumber and got it running now! Thank you bro!