Earn by twitter on twivert

Sign up for PayPal and start accepting credit card payments instantly.

Sunday, January 3, 2010

WAP to check no. is armstrong/not


/*WAP to check no. is armstrong/not*/

import java.lang.*;
class arms
{
int num,i,rem,sum=0,status,b;
arms(int a)
{
num=a;
}
void calculate()
{
i=num;
while(i>0)
{
rem=i%10;
b=rem*rem*rem;
sum=sum+b;
i=i/10;
}
if(sum==num)
status=1;
else
status=0;
}
void display()
{
if(status==1)
System.out.println("ARMSTRONG"+sum);
else if(status==0)
System.out.println("not Armstrong"+sum);
}
}
class demo_arms
{
public static void main(String arg[])
{
arms a1=new arms(153);
a1.calculate();
a1.display();
}
}

No comments:

Post a Comment

ADS

How to earn online

How to earn online:
Step - 1 :
signup for PayPal, to recieve your online earning
click here:
https://www.paypal.com/in/mrb/pal=CZ7224TZBMCBL
step - 2 : Singup these 4 sites & earn & enjoy! Read site to know how to earn.
1. trekpay
Earn up to $0.02 (2 cents) per click.
http://www.trekpay.com/?ref=34690
2. neobux
Earn up to $0.02 (2 cents) per click.
Click here:
http://www.neobux.com/?r=Moneyearner786

AddMe

Bookmark and Share