VND Openxmlformats-Officedocument Wordprocessingml Document&rendition 1

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 11

import java .util.

*;//java package included

public class matrix

public static void main ( String args[])

Scanner sc=new Scanner( System.in);

System.out.println( "Enter the value of M");

int M=sc.nextInt();

if (M>2&&M<10)

int s=0;//variable initialisation

int A[][]=new int [M][M];

System.out.println(" Enter the elements of the array");

for ( int i=0;i<M;i++)

for ( int j=0;j<M;j++)

A[i][j]=sc.nextInt();

System.out.println( "Original matrix is:");


for ( int i=0;i<M;i++)

for ( int j=0;j<M;j++)

System.out.print( A[i][j]+"\t");

System.out.println("" );

System.out.println( "Rotated matrix is:");

for ( int i=0;i<M;i++)

for ( int j=(M-1);j>=0;j--)

System.out.print( A[j][i]+"\t");

if( i==0&&j==(M-1)||j==0&&i==(M-1)||i==(M-1)&&j==(M-1)||i==0&&j==0)

s=s+A[i][j];

System.out.println("" );

}
System.out.println(" The sum of the elements at the four corners is : "+ s);// the sum is displayed

else

System.out.println( "Invalid input");

mport java .util.*;//java package included

public class symmetry

public static void main ( String args[])

Scanner sc=new Scanner( System.in);

System.out.println( "Enter the value of M");

int M=sc.nextInt();

int A[][]=new int [M][M];

int c=0;//variable initialisation

System.out.println(" Enter the elements of the array");

for ( int i=0;i<M;i++)


{

for ( int j=0;j<M;j++)

A[i][j]=sc.nextInt();

System.out.println( "Inputted matrix is:");

for ( int i=0;i<M;i++)

for ( int j=0;j<M;j++)

System.out.print(A[i][j]);//displays the inputted matrix

System.out.println( "");

for ( int i=0;i<M;i++)

for ( int j=0;j<M;j++)

if( A[i][j]!=A[j][i])

c=0;

}
}

if(c==1)

System.out.println(" It is a symmetric matrix");

else

System.out.println(" It is not a symmetric matrix");

import java .util.*;//java package included

public class mirror

public static void main ( String args[])

Scanner sc=new Scanner( System.in);

System.out.println( "Enter the value of M");

int M=sc.nextInt();

if (M>2&&M<280)

int s=0;//variable initialisation

int A[][]=new int [M][M];


System.out.println(" Enter the elements of the array");

for ( int i=0;i<M;i++)

for ( int j=0;j<M;j++)

A[i][j]=sc.nextInt();

System.out.println( "Original matrix is:");

for ( int i=0;i<M;i++)

for ( int j=0;j<M;j++)

System.out.print( A[i][j]+"\t");

System.out.println("" );

System.out.println( "Mirrored matrix is:");

for ( int i=0;i<M;i++)

for ( int j=2;j>=0;j--)

{
System.out.print( A[i][j]+"\t");

System.out.println("" );

import java .util.*;//java package included

public class natural

public static void main ( String args[])

Scanner sc=new Scanner( System.in);

System.out.println( "Enter a integer less than 10,000");

int n=sc.nextInt();

int a[]=new int[4];

String ar[]={"ONE" ,"TWO","THREE","FOUR","FIVE","SIX","SEVEN","EIGHT","NINE"};//array


initialisation

String ar1[]={"TEN","TWENTY","THIRTY","FORTY","FIFTY","SIXTY","SEVENTY","EIGHTY","NINETY"};

String ar2[]={ "ELEVEN


","TWELVE","THIRTEEN","FOURTEEN","FIFTEEN","SIXTEEN","SEVENTEEN","EIGHTEEN","NINETEEN"};

int n1=n,i=4;
while(n1>0)

a[--i]=n1%10;

n1=n1/10;

while(i!=0)

a[--i]=0;

if(a[0]!=0)

System.out.print( ar[a[0]-1]+" "+"THOUSAND"+" ");

if(a[1]!=0)

System.out.print( ar[a[1]-1]+" "+"HUNDRED"+" ");

if(a[2]!=0)

if(a[2]>=2)

System.out.print( ar1[a[2]-1]+" ");

}
if(a[2]==1)

System.out.print( ar2[a[2]-1]+" ");

if (a[2]!=0&&a[3]!=0)

System.out.print( ar[a[3]-1]+" ");

else

if (a[2]==0&&a[3]!=0)

System.out.print( ar[a[3]-1]+" ");

System.out.println( "Enter another integer less than 10,000");

int m=sc.nextInt();

int m1=m;

i=4;//variable initialisation

while(m1>0)

a[--i]=m1%10;

m1=m1/10;
}

while(i!=0)

a[--i]=0;

if(a[0]!=0)

System.out.print( ar[a[0]-1]+" "+"THOUSAND"+" ");

if(a[1]!=0)

System.out.print( ar[a[1]-1]+" "+"HUNDRED"+" ");

if(a [2]!=0)

if(a[2]>=2)

System.out.print( ar1[a[2]-1]+" ");

if(a[2]==1)

System.out.print( ar2[a[2]-1]+" ");


}

if (a[2]!=0&&a[3]!=0)

System.out.print( ar[a[3]-1]+" ");

else

if (a[2]==0&&a[3]!=0)

System.out.print( ar[a[3]-1]+" ");

You might also like