Several multiplication tables, (use do while) Learn programming Java

Lesson:

Flow Control


Exercise:

Several multiplication tables, (use do while)


Objetive:

Display multiplication tables from 2 to 6 using nested "do...while" loops.


Code:

public class Main
{
	public static void main(String[] args)
	{
		int num, multiplier;
		num = 2;

		do
		{
			multiplier = 1;
			do
			{
				System.out.printf("%1$s x %2$s = %3$s" + "\r\n", num, multiplier, num * multiplier);
				multiplier++;
			} while (multiplier <= 10);

			System.out.println();
			num++;

		} while (num <= 6);
	}
}

Juan A. Ripoll - Systems Tutorials and Programming Courses ©  All rights reserved.  Legal Conditions.