Having trouble with math magic. Not sure why im getting so many errors, formatting? any help appreciated


#1

here's my code

public class Magic {
public static void main(String[] args) {

}
}
myNumber = 20;
stepOne = myNumber * myNumber;
stepTwo = stepOne + myNumber;
stepThree = stepOne / myNumber;
stepFour = stepThree + 17;
stepFive = stepFour - myNumber;
stepSix = stepFive / 6;
System.out.println(stepSix);

and here are my errors

Magic.java:7: error: class, interface, or enum expected

myNumber = 20;
^
Magic.java:8: error: class, interface, or enum expected
stepOne = myNumber * myNumber;
^
Magic.java:9: error: class, interface, or enum expected
stepTwo = stepOne + myNumber;
^
Magic.java:10: error: class, interface, or enum expected
stepThree = stepOne / myNumber;
^
Magic.java:11: error: class, interface, or enum expected
stepFour = stepThree + 17;
^
Magic.java:12: error: class, interface, or enum expected
stepFive = stepFour - myNumber;
^
Magic.java:13: error: class, interface, or enum expected
stepSix = stepFive / 6;
^
Magic.java:14: error: class, interface, or enum expected
System.out.println(stepSix);
^
8 errors

any help would be awesome. thanks in advance!!


#2

Move all this

into the main method

i.e between the two curly braces


#3

@rydan I tried that and still threw the same errors.

public class Magic {
public static void main(String[] args) { myNumber = 20;
  stepOne = myNumber * myNumber;
  stepTwo = stepOne + myNumber;
  stepThree = stepOne / myNumber;
  stepFour = stepThree + 17;
  stepFive = stepFour - myNumber;
  stepSix = stepFive / 6;
System.out.println(stepSix);

    

}

}


#4

You need to give myNumber a type.

int myNumber = 20;

You need to also do that for every variable.