problem: 2.7


 Question 2.7: 
Write a Java program that takes a number as input and prints its multiplication table upto

10.

Test Data:

Input a number: 8

Expected Output:

8 x 1 = 8

8 x 2 = 16

8 x 3 = 24

8 x 10 = 80


Solution: 

package com.company;

import java.util.Scanner;

public class lab2Problem07 {

    public static void main(String[] args)
    {
        Scanner Obj = new Scanner(System.in);
        System.out.println("Input a number: ");
        int n = Obj.nextInt();
        for(int i=0;i<=10;i++)
        {
            int r = n*i;
            System.out.println(n +"x"+ i + "="+r);
        }
    }
}

Previous Post Next Post