Write a Java program that takes a number as input and prints its multiplication table upto 10

 Test Data:


Input a number: 8

Java Code:


import java.util.Scanner;

 

public class Exercise7 {

 

 public static void main(String[] args) {

  Scanner in = new Scanner(System.in);

   

  System.out.print("Input a number: ");

  int num1 = in.nextInt();

   

  for (int i=0; i< 10; i++){

   System.out.println(num1 + " x " + (i+1) + " = " + 

     (num1 * (i+1)));

  }

 }

}


Sample Output:


Input a number: 8                                                                                             

8 x 1 = 8                                                                                                     

8 x 2 = 16                                                                                                    

8 x 3 = 24                                                                                                    

8 x 4 = 32                                                                                                    

8 x 5 = 40                                                                                                    

8 x 6 = 48                                                                                                    

8 x 7 = 56                                                                                                    

8 x 8 = 64                                                                                                    

8 x 9 = 72                                                                                                    

8 x 10 = 80 

Post a Comment

0 Comments