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{int k=a+j*b;
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);
}
}
}
}
}


Related Articles

Program for Addition performer in Java

This article provides a description to the addition performer in Java, that can perform addition operation on two input numbers. Code for the addition performer is provided in the article. The program is based on use of Swings. In Java Frames can be created and different text fields alongwith labels corresponding to them can be added. And use of all these elements can develope an efficient adder.

Directory Structure - XML Output

In this article, I have submitted a Java program. We will be able to get the dynamic XML file with treeview represents a folder and file structure of a given folder path using it. This Java program also show how to use a recursive function to read a directory structure and then save it to XML file. I commented properly for your better understanding how the program flow goes. The output XML file is well-formed

Java Based Voice Recognition System

This Java based Voice recognition system project gives a solution developed to communicate between different users using both voice and message. It is an application that provides a good user interface with all the facilities of a chat and voice application. This resource includes requirements, hard requirements and java code.

Looping statements in Java (For, While, Do-While)

Looping statements are statements which are used to repeat set of statements until some condition get false. Here example and description of looping statements For, While and Do..While in java is given. Each looping statements has its own characteristic based on it it used.

JAVA Program For Round Robin Scheduling (Without Priority)

Round Robin scheduling is one of the simplest scheduling method. It assigns time slices equally to all processes, which avoids starvation.Following is a Java program to implement Round Robin scheduling, giving an idea about how this type of scheduling is implemented.

More articles: JAVA program

Comments



  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: