CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 2 FirstFirst 12
Results 16 to 18 of 18

Thread: Java Challenge

  1. #16
    Join Date
    Dec 2011
    Posts
    26

    Smile Re: Java Challenge

    try this one.......




    public class Problemconverter {

    public static void convert(String s){
    int len = s.length();
    String next;
    int count = 1;
    if (len == 0)
    return ;
    else if(len == 1)
    System.out.println(count+""+s.charAt(0));
    else{
    for(int i=0; i<len; i++){
    if(s.charAt(i) == s.charAt(i+1)){
    count++;
    }
    else break;
    }
    System.out.print(count+""+s.charAt(0));

    next = s.substring(count);
    convert(next);

    }
    }
    public static void main(String[] args) {

    convert("10444221");
    }
    }

  2. #17
    Join Date
    May 2006
    Location
    UK
    Posts
    4,473

    Re: Java Challenge

    Why are you guys so keen to do someone else's homework for them?

    It doesn't help the OP at all because he/she won't learn anything from this assignment and so almost certainly won't be able to do the up coming assignments.

    By all means provide guidance but please stop providing the code.
    Posting code? Use code tags like this: [code]...Your code here...[/code]
    Click here for examples of Java Code

  3. #18
    Join Date
    Dec 2011
    Posts
    26

    Re: Java Challenge

    @keang.......

    got it......man.......

    will provide only guidance here after.......

Page 2 of 2 FirstFirst 12

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured