Answers for "Java program to print multiplication table of any number"

0

Java program to print multiplication table of any number

import java.util.Scanner;
public class MultiplicationTablesInJava
{
   public static void main(String[] args)
   {
      System.out.println("Please enter an integer to print tables : ");
      Scanner sc = new Scanner(System.in);
      int number = sc.nextInt();
      System.out.println("Multiplication table of " + number + " is : ");
      for(int a = 1; a <= 10; a++)
      {
         System.out.println(number + " * " + a + " = " + number * a);
      }
      sc.close();
   }
}
Posted by: Guest on January-15-2021
-3

Multiplication table for number Java

public static String multiTable(int num) {
        StringBuilder sb = new StringBuilder();

        for (int i = 1; i <= 10; i++) {
            int result = i * num;
            sb.append(i + " * " + num + " = " + result + "\n");
        }
        return sb.toString().trim();
    }
Posted by: Guest on November-25-2020

Code answers related to "Java program to print multiplication table of any number"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language