Answers for "multiplication table in java"

1

Multiplication table in java using array

// Multiplication table in java using array
public class MultiplicationTableUsingArray
{
   public static void main(String[] args)
   {
      int[][] arrMultipleTable = new int[10][10];
      int row = 1, column = 1;
      for(int a = 0; a < arrMultipleTable.length; a++)
      {
         for(int b = 0; b < arrMultipleTable[a].length; b++)
         {
            arrMultipleTable[a][b] = row * column;
            column = column + 1;
         }
         row = row + 1;
         column = 1;
      }
      for(int a = 0; a < arrMultipleTable.length; a++)
      {
         for(int b = 0; b < arrMultipleTable[a].length; b++)
         {
            System.out.print(" " + arrMultipleTable[a][b] + "\t| ");
         }
         System.out.print("\n");
      }
   }
}
Posted by: Guest on February-19-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 "multiplication table in java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language