do-while:
do
{
i++;
++j;
System.out.println( i * j );
}
while ((i < 10) && (j*j != 25));
I am learning about do-w
Do-While loops are pretty useful for cases like these, where you ask the user a question, and the user has to answer it for the program to terminate. For example, this code:
import java.util.Scanner;
public class DoWhile {
public static void main(String[] args) {
int answer;
do {
System.out.println("What is 5+5?");
Scanner scan = new Scanner(System.in);
answer = scan.nextInt();
} while (answer != 10);
}
}