calling main method to cause the program to run repeatedly

I am writing 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 in 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();

}

}

}

}

}

[1570 byte] By [stu_javaa] at [2007-11-26 20:02:52]
# 1

class Example {

public static void main(String[] args) {

Scanner scanner = new Scanner(System.in);

String response = null;

do {

doStuff();

System.out.print("Would you like to try again, y or n? ");

response = scanner.nextLine();

} while("y".equalsIgnoreCase(response);

}

public static void doStuff() {

// code

}

}

Untested.

floundera at 2007-7-9 23:02:22 > top of Java-index,Java Essentials,New To Java...
# 2
One Qustion do You use the same code that you used before or is there something else this is the part I do not understand .
stu_javaa at 2007-7-9 23:02:22 > top of Java-index,Java Essentials,New To Java...
# 3
you place all your logic and codes within the doStuff() method, so it will just keep looping as long as the user inputs Y to continue. Only when the user inputs N then loop wil stop.
damoona at 2007-7-9 23:02:22 > top of Java-index,Java Essentials,New To Java...
# 4
I have attempted this several time the thing I did not have was the do stuff but still is not invoking the program to rum again it just ignores it.Thank you for the do stuff but maybe you can see why it still does not work. Your nhelp is greatly appreciated.
stu_javaa at 2007-7-9 23:02:22 > top of Java-index,Java Essentials,New To Java...
# 5

your program now:

main(){

//do something

}

needs to be:

main(){

do{

//do something

}while(user say stop)

}

Icycoola at 2007-7-9 23:02:22 > top of Java-index,Java Essentials,New To Java...
# 6
Ok I am confused does that replace the do stuff in multiplication1 or does it go into main.
stu_javaa at 2007-7-9 23:02:22 > top of Java-index,Java Essentials,New To Java...
# 7
Just warp almost everything in your main method with the loop. That will lead to infinite loop most of the time, but I'll leave that to you.
Icycoola at 2007-7-9 23:02:22 > top of Java-index,Java Essentials,New To Java...
# 8
I am very new to this only 4 th program had no problem with the othersdon,t understand what you mean could you explain a little more.
stu_javaa at 2007-7-9 23:02:22 > top of Java-index,Java Essentials,New To Java...
# 9

First thing first, the main method will only run once when you execute the program, so how do you make the contents loop many times? Yeah you put everything in main method in a loop!

main(){

eat apple;

}

I eat apple once here

main(){

loop 3 times{

eat apple

}

}

I eat 3 apples now

Icycoola at 2007-7-9 23:02:22 > top of Java-index,Java Essentials,New To Java...
# 10
This did not work nothing but errors we have to disign program to call method. On mutiplication1 one I get no errors it just does not function.thanks for the advice.
stu_javaa at 2007-7-9 23:02:23 > top of Java-index,Java Essentials,New To Java...
# 11
Thanks very much flounder you really help me to get this working.
stu_javaa at 2007-7-9 23:02:23 > top of Java-index,Java Essentials,New To Java...