Multiplication table program in java

Multiplication table program in java

In mathematics, a multiplication table is a mathematical table used to define a multiplication operation for an algebraic system.

Algorithm

1. Take the number from the user (number)
2. Iterate from 1 to 10 using for loop (i)
3. Multiply the number with i in the for loop (i*10)
4. Print the result

Multiplication table program

package com.answersz.programs;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class MultiplicationTableProgram {

// multiplication table program in java
public static void main(String[] args) throws NumberFormatException,IOException {

BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter number to print its multiplication table");
int number = Integer.parseInt(br.readLine());

for (int i = 1; i <= 10; i++)
System.out.println(number + " x " + i + " = " + (number * i));
}
}

Output

Enter number to print its multiplication table
9
9 x 1 = 9
9 x 2 = 18
9 x 3 = 27
9 x 4 = 36
9 x 5 = 45
9 x 6 = 54
9 x 7 = 63
9 x 8 = 72
9 x 9 = 81
9 x 10 = 90

Chuyên mục

Bài viết mới

GiottoPress by Enrique Chavez