This program displays the table of the number entered by the user using the Scanner class.
Java program to print the multiplication table of a number
import java.util.Scanner;
public class Table {
public static void main(String args[]) {
System.out.println("Enter number ");
Scanner inputReader = new Scanner(System.in);
int a = inputReader.nextInt();
int n,b;
for( n=1;n<=10;n++)
{
b=n*a;
System.out.println("Table is"+b);
}
}
}
Output of the program is:
Java program to print the multiplication table of a number
import java.util.Scanner;
public class Table {
public static void main(String args[]) {
System.out.println("Enter number ");
Scanner inputReader = new Scanner(System.in);
int a = inputReader.nextInt();
int n,b;
for( n=1;n<=10;n++)
{
b=n*a;
System.out.println("Table is"+b);
}
}
}
Output of the program is:
0 comments: