Search This Blog

Loading...

Wednesday, July 15, 2015

BlueJ Program on Neon Numbers Between 1 and 500



import java.io.*;
class Neon
{
int i,sq,sum=0;
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
public void showNeon() throws Exception
{
for(i=1;i<=500;i++)
{
sum=0;
 sq=i*i;
 while(sq>=1)
{
 sum=sum+sq%10;
 sq=sq/10;
}
if(i==sum)
 System.out.println(i+ " is a neon number");
}
}
public static void main(String args[])throws Exception
{
 Neon ob=new Neon();
ob.showNeon();
}
}

Saturday, June 6, 2015

BlueJ Program on patter 1 ! 12 ! 123 ! 1234 !



A pattern like this to be displayed using Java program.

1
!
12
!
123
!
1234
!

class A
{
 public void showPattern()
 {
 int i,j,x=0,c;
 for(i=0;i< 7;i++)
 {
 c=1;
  if(i%2!=0)
  System.out.print("   !");
  else
  {
   x++;
  for(j=0;j< x;j++)
  System.out.print("   "+c++);
 }
  System.out.println();
  }
  }
   public static void main(String args[])throws Exception
  {
   A ob=new A();
   ob.showPattern();
   }
   }


CHECK HERE FOR PREVIOUS POSTS

Google+ Followers

Subscribe via email

Enter your email address:

Delivered by FeedBurner