Results 1 to 5 of 5

Thread: Actions

  1. #1
    What2do is offline Member
    Join Date
    Jan 2011
    Posts
    2
    Rep Power
    0

    Default 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. #2
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,641
    Rep Power
    7

    Default

    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. #3
    What2do is offline Member
    Join Date
    Jan 2011
    Posts
    2
    Rep Power
    0

    Default

    I need help!

  4. #4
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,641
    Rep Power
    7

    Default

    Quote Originally Posted by What2do View Post
    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. #5
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,091
    Rep Power
    20

    Default

    For starters your code has no formatting whatsoever...at least you managed to find the code tags (which is one up on many).

Similar Threads

  1. actions for buttons
    By steel in forum AWT / Swing
    Replies: 1
    Last Post: 12-02-2010, 05:42 AM
  2. JSP standard actions
    By subhashis_mohanty in forum JavaServer Pages (JSP) and JSTL
    Replies: 2
    Last Post: 11-27-2010, 07:35 AM
  3. How to Use Actions
    By AJArmstron@aol.com in forum New To Java
    Replies: 4
    Last Post: 04-18-2010, 09:03 PM
  4. Button Actions
    By vasavi.singh in forum Advanced Java
    Replies: 3
    Last Post: 04-03-2009, 09:50 PM
  5. Actions
    By alley in forum AWT / Swing
    Replies: 2
    Last Post: 01-16-2008, 02:52 PM

Posting Permissions

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