Print multiplication tables for given range

Below is the java source code to print the range of multiplication table.
For an example if you pass the range between 3 to 7 then it will print all the tables starting from 3 until it reaches to 7.
In my case I'm passing two integers 7 and 8 so it will print the multiplication table for 7 and 8.

import java.util.Scanner;

class PrintTables {
    public static void main(String args[]) {
        int firstNumber, secondNumber, range, index;

        System.out
        .println("Enter range of numbers to print their multiplication table");
        Scanner in = new Scanner(System.in);

        firstNumber = in.nextInt();
        secondNumber = in.nextInt();

        for (range = firstNumber; range <= secondNumber; range++) {
            System.out.println("--------------------------");
            System.out.println("Multiplication table of " + range);
            System.out.println("--------------------------");

            for (index = 1; index <= 10; index++) {
                System.out.println(range + "*" + index + " = "
                        + (range * index));
            }
        }
    }
}
Output:
 

2 comments:

  1. If getting issues in QuickBooks, get it resolved by calling QuickBooks Desktop Support Phone Number 1-833-325-0220. Our highly skilled & dedicated experts are available 24/7 to assist you. For More Visit: https://bit.ly/3ersn4D

    ReplyDelete
  2. I really thank you for the valuable info on this great subject and look forward to more great posts. Thanks a lot for enjoying this beauty article with me. I am appreciating it very much! Looking forward to another great article. Good luck to the author! All the best! Multiplication chart

    ReplyDelete