Make corrections in the following Java program.
import java.util.Scanner;
public class Transarray
{
int arr[][];
int m,n;
Transarray()
{
m=0;
n=0;
}
Transarray(int mm,int nn)
{
m=mm;
n=nn;
arr=new int[mm][nn];
}
void fillarray()
{
Scanner sc = new Scanner(System.in);
System.out.println("enter the elements of the array");
for(int i=0;i<m;i++)
{
for(int j=0;j<n;j++)
{
arr[i][j]=sc.nextInt();
}
}
}
void transpose(Transarray A)
{
for(int i=0;i<m;i++)
{
for(int j=0;j<n;j++)
{
this.arr[i][j]=A.arr[j][i];
}
}
}
void display()
{
for(int i=0;i<m;i++)
{
for(int j=0;j<n;j++)
{
System.out.print(arr[i][j]);
}
System.out.println();
}
}
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter the size of the array");
int r=sc.nextInt();
int c=r;
Transarray ob1=new transarray(r,c);
Transarray ob2=new transarray(r,c);
ob1.fillarray();
ob1.display();
ob2.transpose(ob1);
System.out.println("The transpose of the array is:");
ob2.display();
}
}
Answers
Answered by
1
Explanation:
run a proper program ranging from 1-10 with a display of transarray.
enter the element of the transpose in order of
Similar questions