Hey,
I'm trying to make this program which finds the multiples of 7 under 400. Here it is:
And while trying to compile I get this error:
Compile error
Main.java:10: error: cannot find symbol
int y=9*x;
^
symbol: variable x
location: class Main
1 error
Jayanth Raju wrote:Hey,
I'm trying to make this program which finds the multiples of 7 under 400. Here it is:
class Main
{
public static void main (String[] args) throws java.lang.Exception
{
for(int x=1;x<=400;x++);
int y=9*x;
System.out.println(y);
}
}
And while trying to compile I get this error:
Compile error
Main.java:10: error: cannot find symbol
int y=9*x;
^
symbol: variable x
location: class Main
1 error
Anyone can tell me what i've done wrong?
Thanks!
EDIt: I found the problem, please close the thread.
Jayanth Raju wrote: . . .
EDIt: I found the problem, please close the thread.
And what was the problem? You think you can see it, but it is actually that you haven’t formatted your code properly. If you had used braces, it would have been obvious to you.
You should always use code tags; since you are new I have added them and you can see how much better the code looks
I do not believe your program will fulfil its requirements.
1: I think you should stop when you get to 399 = 7 × 57, not 7 × 399
2: You are using 9 not 7.
Getting married means "We're in love, so let's tell the police!" - and invite this tiny ad to the wedding:
a bit of art, as a gift, that will fit in a stocking