Wednesday, 11 November 2020

Java Program to Print Tables by taking input from the user

 /* Program to print tables in the following FORMAT

Input: 4

4 x 1 = 4

4 x 2 = 8

4 x 3 = 12

4 x 4 = 16

4 x 5 = 20

4 x 6 = 24

4 x 7 = 28

4 x 8 = 32

4 x 9 = 36

4 x 10 = 40

*/

import java.util.*;

public class Table

{

    public static void main(String args[])

    {

        Scanner in=new Scanner(System.in);

        int n,i;

        System.out.println("Enter a Number");

        n=in.nextInt();

        for(i=1;i<=10;i++)

        System.out.println(n+" x "+i+" = "+(i*n));

    }

}

No comments:

Post a Comment

Java Program to count the total number of characters in a string

 //Java Program to count the total number of characters in a string import java.util.*; public class CountChars {     public static void mai...