Odd numbers descending Learn programming Java

Lesson:

Flow Control


Exercise:

Odd numbers descending 11


Objetive:

Create a java program to display on the screen the odd numbers from 15 to 7 (downwards), using "while"


Code:

import java.util.*;
public class Main
{
	public static void main(String[] args)
	{
		int num, multiplier = 1;

		System.out.print("Insert a number to multiply: ");
		num = Integer.parseInt(new Scanner(System.in).nextLine());

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