BlueJ Programs

Saturday, September 24, 2011









BlueJ 3.0.5 is now available for download! It includes JUnit 4 support (many thanks to Patrick Doran-Wu at the University of Western Australia), and support for the language features introduced with Java 7, as well as a large number of minor bug fixes.



There are some Programs and the Data Types Listed here at the moment. I plan to add many more programs.



Here is a Program below that you can checkout, its to check is a number is a Kaprekar Number.


A Program to check weather the number is a Kaprekar Number.


Kaprekar Numner Defination:A posotive whole number 'n' that has 'd' number of digits is squared and split into
2 pieces, a right hand piece that has 'd' digits and a left hand piece that has
remaining 'd' or 'd-1' digits. If sum of the pieces is equal to the number then
it's a kaprekar number.


Few Known Kaprekar numbers: 1,9,45,55,99

class KaprekarCheker
{
public static void main(int a)
{
int digits=0,square=0,firstd=0,secondd=0;
int modder=1;
final double original=a;
square=a*a;
String len="";
len=len+a;
int leng=len.length();
while(leng>0){
modder*=10;
leng-=1;}
firstd=square%modder;
secondd=square/modder;
if((firstd+secondd)==original){
System.out.print("Kapekar");
}
else
System.out.print("Not Kaprekar");
}
}


Input: 45,555,999


Output:

45

555

999

As you can see, its working fine.