Tuesday 5 February 2013

multiplication table in java


import java.util.Scanner;

class MultiplicationTable
{
   public static void main(String args[])
   {
      int number, a;
      System.out.println("which table you want");
      Scanner in = new Scanner(System.in);
      number = in.nextInt();
      System.out.println("Multiplication table of "+number+" is :-");

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


Output: 
  
                 

which table you want
4
Multiplication table of 4 is :-
4*1 = 4
4*2 = 8
4*3 = 12
4*4 = 16
4*5 = 20
4*6 = 24
4*7 = 28
4*8 = 32
4*9 = 36
4*10 = 40

No comments:

Post a Comment