Search This Blog

Sunday, April 11, 2010

As the ICSE exam is over, we can talk something about the questions that came there in Comp. Appl. paper. There was a mixed response from the students regarding this year's question paper. If you want to share your views you feel free to do so.






Discussing Java application programming across the barrier of classroom for the young minds.

Thursday, March 25, 2010

I wish all ICSE examinees the very best for tomorrows Computer Application test.


Discussing Java application programming across the barrier of classroom for the young minds.
//Pascal's Triangle- the mathematical way
class Pascal
{
double fact(double n)
{

return (n > 1) ? n * fact(n - 1) : 1;

}
double ncr(int n, int r)
{

return fact(n) / (fact(r) * fact(n - r));

}
void generate()
{
for (int i = 0; i < 15; i++)
{
for (int j = 0; j <= i; j++)
{
System.out.print((int)ncr(i, j));
}
System.out.println(" ");
}
}
}

//As per Request from Tanmoy.
Discussing Java application programming across the barrier of classroom for the young minds.
//Fibonacci Recursive Way:

class RecFibo
{
void series(int term)
{
for(int i=1; i<=term;i++)
{
System.out.println(fibo(i));
}
}
double fibo(int n)
{
if(n<=2.0)
return 1.0;
else
return fibo(n-1)+fibo(n-2);
}
}

//If you don't want very long series, you may change double to int and put the '.0' off from the rear side of the numbers.


Discussing Java application programming across the barrier of classroom for the young minds.
Fibonacci Series Ordinary Way:

public class Fibo
{
public void display(int term)
{
int t1=0,t2=1,t=t1+t2;
for(int i=1;i<=term;i++)
{
System.out.print(t+" ");
t=t1+t2;
t1=t2;
t2=t;
}
}
}




Discussing Java application programming across the barrier of classroom for the young minds.

Wednesday, March 17, 2010

Q.Enter a year and test whether it is a leap year or not, shorter way.....

Ans.

public class LeapYearAnother
{
public boolean isLeapYear(int year)
{
return((year%4==0) && (year%100!=0) || (year%400==0))?true:false;
}
}








Discussing Java application programming across the barrier of classroom for the young minds.
Q. Input a year in the method call box as argument and get the result from method return dialog box. true means the entered year is a leapyear, otherwise not.
Ans.

public class LeapYear
{
public boolean isLeapYear(int year)
{

if (year < 0) {
return false;
}
if (year % 400 == 0) {
return true;
} else if (year % 100 == 0) {
return false;
} else if (year % 4 == 0) {
return true;
} else {
return false;
}
}

}

Discussing Java application programming across the barrier of classroom for the young minds.