Program to display Java Multiplication Table

By | 2018-03-21T21:51:12+05:30 June 15th, 2016|java programs|

Here we are going to write a program to display Java multiplication table for given number.

Input : Give Table Number : 7

Output :

7*1=7
7*2=14
7*3=21
7*4=28
7*5=35
7*6=42
7*7=49
7*8=56
7*9=63
7*10=70


package com.onlinetutorialspoint.javaprograms;

import java.util.Scanner;

public class MultiplicationTable {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        System.out.print("Enter Table number : ");
        int number = sc.nextInt();
        Logic logic = new Logic();
        logic.set(number);
        logic.table();
    }
}

class Logic // Business Logic Class (BLC)
{
    int n;

    void set(int x) {
        n = x;
    }

    void table() {
        for (int i = 1; i <= 10; i++) {
            int res = n * i;
            System.out.println(n + "*" + i + "=" + res);
        }
    }
}

Output :

Enter Table number : 7
7*1=7
7*2=14
7*3=21
7*4=28
7*5=35
7*6=42
7*7=49
7*8=56
7*9=63
7*10=70

Happy Learning 🙂

About the Author:

Hi Folks, you have reach this so far, that shows you like what you are learning. Then why don't you support us to improve for bettor tutorials by leaving your valuable comments and why not you keep in touch with us for latest updates on your favorite blog @ facebook , twitter , Or Google+ ,

Leave A Comment