class digits
{
public static void main(String args[])
{
int dig=Integer.parseInt(args[0]);
int sum=0,rev=0;
float avg;
int len=args[0].length();
while(dig>0)
{
int r=dig%10;
sum=sum+r;
dig=dig/10;
rev=rev*10;
rev=rev+r;
}
avg=(float)sum/len;
System.out.println("The sum of digits is: "+sum);
System.out.println("The length of number is: "+len);
System.out.println("The average of the digits is: "+avg);
System.out.println("The reverse of digits is: "+rev);
}
}
Tuesday, July 3, 2012
Sum of digit, Length of number, average and reverse of digit program in java
To find Sum of digit, Length of number, average of digit and reverse of digit program in java
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment