Java Program to print Multiplication Table of any Number - The Coding Shala

Home >> Java Programs >> Print Multiplication Table in Java

 In this post, we will learn How to Generate a Multiplication Table of any Number using a Java Program.

Java Program to Print Multiplication Table of any Number

We will take a number input from the user and will generate a multiplication table of that number using Java loops. We can use for loop or while loop here. The Java Program of Multiplication Table is below:

Java Program: 

/**
 * https://www.thecodingshala.com/
 */

import java.util.*;

public class Main {

    public static void printTable(int num) {
        for(int i = 1; i <= 10; i++) {
            System.out.println(num + " * " + i + " = " + num*i);
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("Enter a number");
        int num = sc.nextInt();
        printTable(num);
    }
}

Output: 

Enter a number
9
9 * 1 = 9
9 * 2 = 18
9 * 3 = 27
9 * 4 = 36
9 * 5 = 45
9 * 6 = 54
9 * 7 = 63
9 * 8 = 72
9 * 9 = 81
9 * 10 = 90


Other Posts You May Like
Please leave a comment below if you like this post or found some errors, it will help me to improve my content.

Comments

Popular Posts from this Blog

Shell Script to Create a Simple Calculator - The Coding Shala

N-th Tribonacci Number Solution - The Coding Shala

Java Program to Convert Binary to Decimal - The Coding Shala

LeetCode - Shuffle the Array Solution - The Coding Shala

Java Program to Find GCD or HCF of Two Numbers - The Coding Shala