calling main method to cause the program to run repeatedly

I am righting a multiplication program and need to call method main to reinvoke the progam to start over if user enters correct answer. I am really not understanding this at all have search internet and have not found a solution that does not give an error. Everything else the program works as it issupposed to with no problems. I am posting code

I am just learning java and my teachers is unavailable this week. I would greatly appreciate suggetion and input so I can learn this

Thanks

package multiplication;

import java.util.Random;

import java.util.Scanner;.

public class Multiplication {

/** Creates a new instance of Multiplication */

public Multiplication() {

}

/**

*

* @param args the command line arguments

*/

public static void main(String[] args) {

for ( int counter=1; counter <=1; counter++); {

int i = 1 + (int)(Math.random() * 9);

System.out.printf("How much is %s ", i );

{ for( int counter =1; counter <= 1; counter++);

int j= 1 + (int)(Math.random() * 9);

System.out.printf( "* %s ", j );

Scanner ScannerObject = new Scanner(System.in);

System.out.println();

int s = ScannerObject.nextInt();

{ if (s == i * j)

System.out.println("Very Good ");

if

(s != i * j)

System.out.println(" Please Try Again ");

while(s != i * j)

s = ScannerObject.nextInt();

System.out.println();

System.out.println();

}

}

}

}

}

[1568 byte] By [stu_javaa] at [2007-11-26 20:02:49]
# 1

A couple of things strike me: firstly, your for loops don't seem to go anywhere -- for int i = 1 to int i <=1 means it can only execute once (by my reading). Secondly, placing long methods inside the main method isn't a great idea. Separate out different parts of the program.

You could use a boolean variable to check whether the right answer has been input and keep going if it has.

Tavea at 2007-7-9 23:02:14 > top of Java-index,Java Essentials,New To Java...
# 2
> for ( int counter=1; counter <=1; counter++); You do realize that that little trailing semicolon spoils it all don't you?kind regards,Jos
JosAHa at 2007-7-9 23:02:14 > top of Java-index,Java Essentials,New To Java...
# 3

http://forum.java.sun.com/thread.jspa?threadID=5142572&tstart=0

DON'T DOUBLE POST!

If you didn't get a suitable answer in your other thread then post to it again. By starting another thread you waste peoples time because answers provided here can potentially duplicate what has already been said in your other thread.

Also, when posting code, highlight it and click the code button above message box.

NO MORE RESPONSES HERE PLEASE. USE LINK ABOVE TO PROVIDE ADVICE.

floundera at 2007-7-9 23:02:14 > top of Java-index,Java Essentials,New To Java...