Answers for "allintitle:Java program to print 3x3 matrix"

1

Java program to print 3x3 matrix

// Java program to print 3x3 matrix
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class JavaPrint3x3Matrix
{
   public static void main(String[] args) throws IOException 
   {
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      int[][] inputNumber = new int[3][3];
      int a, b;
      String strMatrix;
      System.out.println("Please enter elements to print 3x3 matrix: ");
      for(a = 0; a <= 2; a++)
      {
         for(b = 0; b <= 2; b++)
         {
            strMatrix = br.readLine();
            inputNumber[a][b] = Integer.parseInt(strMatrix);
         }
      }
      System.out.println("Elements in 3x3 matrix are: ");
      System.out.println("");
      for(a = 0; a <= 2; a++)
      {
         for(b = 0; b <= 2; b++)
         {
            System.out.print(inputNumber[a][b] + "\t");
         }
         System.out.println();
      }
   }
}
Posted by: Guest on February-18-2021

Code answers related to "allintitle:Java program to print 3x3 matrix"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language