Java Programs
Java Programs
*; }
class Upper_triangle
{ int f=0;
{ {
for(i=0;i<3;i++) f=1;
{ }
for(j=0;j<3;j++){ }
a[i][j]=[Link](); if(f!=1)
} [Link]("upper triangle
matrix");
else
}
[Link]("NOT upper triangle
[Link](); matrix");
for(i=0;i<3;i++) }
{ }
for(j=0;j<3;j++)
import [Link].*;
[Link](a[i][j]+"\t");
class check_rowmajor
[Link]();
{
{
Scanner sc=new Scanner([Link]); for(j=0;j<3;j++)
int s=0;
for(i=0;i<3;i++) sort(rm);
{ for(i=0;i<9;i++)
for(j=0;j<3;j++) [Link](rm[i]);
a[i][j]=[Link]();
for(i=0;i<3;i++)
} for(j=0;j<3;j++)
for(i=0;i<3;i++)
for(j=0;j<3;j++) }
[Link](); for(i=0;i<3;i++)
} for(j=0;j<3;j++)
[Link](a[i][j]+" ");
int k=0;
for(i=0;i<3;i++) }
{ }
static void sort(int t[]) int n=[Link]();
{ for(i=0;i<n;i++)
for(j=0;j<9-1-i;j++) {
{ for(j=0;j<n;j++)
if(t[j]>t[j+1]) a[i][j]=[Link]();
{ }
temp=t[j];
t[j]=t[j+1]; for(i=0;i<n;i++)
t[j+1]=temp; {
} for(j=0;j<n;j++){
} if(i==0||j==0||i==n-1||j==n-1)
} s=s+a[i][j];
} else
} p=p*a[i][j];}
import [Link].*;
class sum_product_boundry_elements }
{ [Link]("Product"+" "+p);
[Link]("enter size"); }
***************************************
}
import [Link].*;
class Unit_matrix_check
int f=0;
{
for(i=0;i<3;i++)
static void main()
{
{
for(j=0;j<3;j++)
Scanner sc=new Scanner([Link]);
{
[Link]("enter the array 1st");
if(i!=j&&a[i][j]!=1)
int a[][]=new int[3][3];
f=1;
int s=0;
if(i==j&&a[i][j]!=0)
int i,j;
f=1;
for(i=0;i<3;i++)
}
{
}
for(j=0;j<3;j++){
if(f!=1)
a[i][j]=[Link]();
[Link]("unit matrix");
}
else
[Link]("enter size"); }
{ Sum(int a,int b)
for(j=0;j<n;j++) {
a[i][j]=[Link](); s=0.0;
} x=a;
n=b;
for(i=0;i<n;i++) }
{ max=a[i][0]; int fact(int n)
for(j=0;j<n;j++) {
{ int f=1,i;
if(a[i][j]>max) for(i=1;i<n;i++)
{ f=f*i;
max=a[i][j]; return f;
[Link]("max of each }
row"+" "+max);}
double calc()
int i,k=2,j=3;
}
for(i=1;i<=n;i++)
}
{ {
k+=2;j+=3; int i;
}return s; for(i=0;i<c;i++)
} {
{ }
[Link](s); [Link]();
[Link]();
}
[Link]();
}
}
static boolean isprime(int n)
}
{ int i;
import [Link].*;
int c=0;
class Check_Array_prime
for(i=1;i<=n;i++)
{
{if(n%i==0)
static void main()
c++;
} {
if(c==2) m=(l+u)/2;
else {f=1;break;}
return false;
} else if(s>a[m])
} l=m+1;
{ }
{ [Link]("found");
int l=0,u=n-1,f=0,m;
while(l<=u) Ranklist(int s)
{ int j;
int i; { if(mark[j]<mark[j+1])
for(i=0;i<size;i++) temp1=mark[j];
{ mark[j]=mark[j+1];
roll[i]=[Link]();} mark[j+1]=temp1;
for(i=0;i<size;i++){ temp=roll[j];
mark[i]=[Link]();} roll[j]=roll[j+1];
for(i=0;i<size;i++){
name[i]=[Link]();} temp2=name[j];
} name[j]=name[j+i];
name[j+i]=temp2;
void prepare() }
{int i; }
} [Link]("Enter the size of first
and second array");
void print()
Scanner sc=new Scanner([Link]);
{ [Link](" ");
int n=[Link]();
[Link]("s\troll\tname\tmark");
int y=[Link]();
for(int i=0;i<size;i++)
[Link]("accept the array");
[Link]((i+1)+"\t "+roll[i]+"\t
"+name[i]+"\t "+mark[i]); int a[]=new int[n];
{ int k=0;
[Link]("2 array");
[Link](); for(i=0;i<y;i++)
[Link](); b[i]=[Link]();
[Link]();
} for(i=0;i<[Link];i++)
} c[k++]=a[i];
*************** for(i=0;i<[Link];i++)
{ for(i=0;i<[Link];i++)
{ }}
import [Link].*; [Link]("equal");
class Reverse_array_check }
{ }
{ int f=0;
if(a[i]!=a[n-i-1]) int i;
{f=1; [Link]("first array");
break; for(i=0;i<n;i++)
} a[i]=[Link]();
} [Link]();
if(f!=0) [Link]("2 array");
[Link]("not equal"); for(i=0;i<y;i++)
else b[i]=[Link]();
[Link](); Scanner sc=new Scanner([Link]);
} int i;
{ for(i=0;i<ct;i++)
if(a[i]!=b[i]) { a=[Link]();
{f=1;break;} isencode(a);
} }
[Link]("not equal"); {
[Link]("equal");
} String s3="";
} l=[Link]();
class Encoding {
{ ch=[Link](i);
{ if(ch=='y')
ch='a'; int j=0;
if(ch=='Y') while(temp!=0)
ch='A'; {
if(ch=='z') temp=temp/10;
ch='b'; c++;
if(ch=='Z')
ch='B'; }
} while(a!=0)
[Link](s3+" "); {
d=a%10;
} a=a/10;
} n[i++]=d;
import [Link].*;
class Descending }
{ int t=0;
{ {
} }
} }
for(i=0;i<[Link];i++){ }
[Link](n[i]);} }
import [Link].*;
} class trail
} {
class Arrange {
{ String s=[Link]();
for(ch='A';ch<='Z';ch++) if([Link]()==1)
{ [Link](a+" ");
for(i=0;i<l;i++) else
{ check(a);
if(ch==[Link](i)){
} [Link]("enter the word");
} String s=[Link]();
{ String a="";
int ct=[Link]();
l=[Link](); [Link](a);
ch=[Link](0); [Link](a);
ch1=[Link](l-1);
s3=[Link](1,l-1); }
b=ch1+s3+ch; }
} {
int l=[Link]();
**************** for(i=l-1;i>=0;i--)
{ }
{ return true;
} for(i=1;i<=n;i++)
} {if(n%i==0)
{ return true;
{ return false;
int i; }
{ {
[Link](i); {
} {
if(i%2==0)
{ else
s=s+([Link](x,k)/fact(j)); n=n/10;
j+=3; if(d>1){
} break;}
int i; }
for(i=1;i<=n;i++) if(c%2==0&&f==true)
return f; else
} }
import [Link].*; }
{ class Febonaci
{ [Link]("0 1");
d=n%10; for(i=1;i<=n;i++)
{
c=a+b; a=b;b=c;
if(isprime(c)==true);
} for(i=10;i<=1000;i++)
} if(isprime(i)==true&&ispalin(i)==true)
{int d=0;
for(p=1;p<=n;p++) }
else { if(n%p==0)
} if(c==2)
} return true;
else
temp=n; switch(ch)
while(n!=0){ {
n=n/10; break;
if(temp==s) break;
else break;
} break;
} case 'E':a=14;
{ break;
s=[Link](); }
int i=0; }
for(i=l-1;i>=0;i--)
{ch=[Link](i);//F
*************** case 13:a="D";
{ case 14:a="E";
{ break;
while(n!=0) }
{ }
d=n%16; **********************
{case 10:a="A"; {
break; {
break; while(n!=0)
{
d=n%2;
int i;
} for(i=0;i<ct;i++)
} {
************************** a=[Link]();
[Link]();
[Link]();
import [Link].*;
class Binarytodec
[Link]("enter binary");
int n=[Link]();
int s=0;
int d=0,i=0;
while(n!=0)
{d=n%10;
n=n/10;
s=s+d*(int)[Link](2,i);
i++;
[Link](s);