Java program to find table of any number
program:
import java.util.*;
class table
{
Scanner sc=new Scanner(System.in);
int n;
void accept()
{
System.out.println("enter the number to print its table");
n=sc.nextInt();
}
void table()
{
String s=Integer.toString(n);// covert integer to string
for(int i=1;i<=10;i++)
{
String x=Integer.toString(i);// covert integer to string
System.out.println(s+ " x " +x+ " = " +n*i);
}
}
void main()
{
table ob=new table();
ob.accept();
ob.table();
}
}
sample output:
Comments
Post a Comment