# Important JAVA Programs For Computer Students For ICSE/ISC/BTech Examination

These programs are written in bluej java computer for icse / isc/ Btech/BscIT/BCA students. First program is permutation-combination type and second program find out the co-primes.Given programs helps to all types of computer students not only for examination but also for their project work.

Q1.A person has n number of sons and n square number of cows.Each cow gives milk as per their serial number. For example cow number 1 gives 1 liter milk, cow number 2 gives 2 liter of milk and so on.Write a program in bluej(java) to solve the above problem**Solution 1:-**

class cows

{

public void abc(int n)

{

int cows=n*n;

int a[][]=new int [n][n];

for(int i=0;i

a[i][i]=i+1;

}

int d=n;

for(int j=0;j

for(int k=0;k

if(j!=k)

{

a[k][j]=d+1;

d=d+1;

}

}

}

for(int p=0;p

int w=p+1;

System.out.print(w+"number son will get cows with serial numbers------");

for(int q=0;q

System.out.print(a[p][q]+",");

}

System.out.println(" ");

}

}

}

** Input number of sons:-5

** Output number of cows:-1number son will get cows with serial numbers------1,10,14,18,22,

2number son will get cows with serial numbers------6,2,15,19,23,

3number son will get cows with serial numbers------7,11,3,20,24,

4number son will get cows with serial numbers------8,12,16,4,25,

5number son will get cows with serial numbers------9,13,17,21,5,

Q2.Program to find out the co prime numbers- written in Bluej(java) **Solution 2:**

class AP

{int s;

public void abc(int a,int b,int n)

{

if(a>b)

{

for(int i=1;i<=b;i++)

{

if(a%i==0)

{

s=s+1;

}

}

if(s==0)

{

System.out.println("The numbers are coprime");

for(int j=0;j

System.out.print(k);

}

}

}

else

{

for(int i=1;i<=a;i++)

{

if(b%i==0)

{

s=s+1;

}

}

if(s==0)

{

System.out.println("The numbers are coprime");

for(int j=0;j

int k=b+j*a;

System.out.print(k);

}

}

}

}

}