1. Member
Join Date
Jan 2011
Posts
2
Rep Power
0

## Actions

a. Write an action that accepts an integer num returns the number of digits
b. Write an action that accepts an integer, and returns the difference between the leftmost digit and the rightmost digit
Use the steps in a.
c. Write a program which takes in 10 pairs of numbers, the program Atedpsat number difference between left digit number is the largest right

Java Code:
```public static int inc(int x){
int count=0;

while(x!=0){
x=x/10;
count++;
}
return  (count);
}

public static int jjj(int y){
int first=0,last=0;

last=y%10;
for(int i=0;i<inc(y);i++){
first=y/10;

}
return(Math.abs( first-last));
}
public static void main(String[] args) {
Scanner in = new Scanner( System.in);
int x;
System.out.println("Enter number");
x=in.nextInt();
System.out.println(jjj(x));
}

}```
What is the problem?

2. Moderator
Join Date
Jul 2010
Location
California
Posts
1,638
Rep Power
13
What is the problem?
You tell us...do you get exceptions? Does it behave in a way which is unexpected (if so do tell)?

3. Member
Join Date
Jan 2011
Posts
2
Rep Power
0
I need help!

4. Moderator
Join Date
Jul 2010
Location
California
Posts
1,638
Rep Power
13
Originally Posted by What2do
I need help!
Did you read my previous post? We have no idea what the problem is because YOU need to tell us. If you want help, I suggest you help those will to lend a hand by reading my previous post and explaining what the problem is. Better yet, read this: How To Ask Questions The Smart Way

5. Moderator
Join Date
Apr 2009
Posts
13,541
Rep Power
27
For starters your code has no formatting whatsoever...at least you managed to find the code tags (which is one up on many).

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•