Multiplication Table in Java
Here, you will learn and get the program code to print the input number multiplication table in java programing.
A multiplication table is a table of numbers which lists product of a decimal sequence of numbers. For example, the table below is a multiplication table of the given number 5.
5 * 1 = 5
5 * 2 = 10
5 * 3 = 15
5 * 4 = 20
5 * 5 = 25
5 * 6 = 30
5 * 7 = 35
5 * 8 = 40
5 * 9 = 45
5 * 10 = 50
Print Multiplication Table in Java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | //Multiplication Table in Java import java.util.Scanner; public class PrintMultiplicationTable { public static void main(String args[]) { int num; System.out.print("\tEnter a number : "); Scanner in = new Scanner(System.in); num = in.nextInt(); System.out.println("\tMultiplication table of " + num + " is :-\n"); for(int i = 1; i <= 10; i++) System.out.println("\t"+ num + " * "+ i +" = " + (num*i)); } } |
Output
C:\CodeRevise\java>javac PrintMultiplicationTable.java
C:\CodeRevise\java>java PrintMultiplicationTable
Enter a number : 25
Multiplication table of 25 is :-
25 * 1 = 25
25 * 2 = 50
25 * 3 = 75
25 * 4 = 100
25 * 5 = 125
25 * 6 = 150
25 * 7 = 175
25 * 8 = 200
25 * 9 = 225
25 * 10 = 250
Check out our other Java Programming Examples