# Actions

• 01-30-2011, 10:09 PM
What2do
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

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?
• 01-30-2011, 10:13 PM
doWhile
Quote:

What is the problem?
You tell us...do you get exceptions? Does it behave in a way which is unexpected (if so do tell)?
• 01-31-2011, 07:04 AM
What2do
I need help!
• 01-31-2011, 03:59 PM
doWhile
Quote:

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
• 01-31-2011, 05:45 PM
Tolls
For starters your code has no formatting whatsoever...at least you managed to find the code tags (which is one up on many).