Results 1 to 2 of 2
  1. #1
    LuluMM is offline Member
    Join Date
    Mar 2012
    Posts
    9
    Rep Power
    0

    Default Making an Encoder

    So I'm making an encoder, and this is an example of how it works:
    input: aaaahh byyyjjjjj
    output: a4h2 by3j5




    I cannot get my program to actually give me any output... any tips/ideas? This is what I have so far.

    Java Code:
    import java.util.Scanner;
    class Encoder{
      public static void main (String[] args){
        
        Scanner in = new Scanner(System.in);
        
        char current=' ';
        
        String words = new String();
        String letters;
        
        
        int total = 1;
        
        int number=0;
        
        boolean code = true;
        
        
        while(in.hasNextLine()){
          letters = in.next();
          letters = letters.toLowerCase();
          
       
          
          if(code){
            for(int index = 1; index < letters.length(); index++){
              if (index == 0){
                words += current;
                continue;
              }
            }
          }
          
          String input = in.nextLine();
          for(int i=0; i<input.length()-1; i++)
          {
            if (input.charAt(number)==input.charAt(number+1)){
              total=total+1;
            }
            else{
              System.out.print(input.charAt(number));
              System.out.print(total);
              total=1;
              current=input.charAt(number+1);
            }
            if(number==total){
              current++;
              
            }
            
            
          }
        }
      System.out.print(current);
          System.out.println(number);
      }
    }
    Last edited by JosAH; 04-19-2012 at 10:38 PM. Reason: added [code] ... [/code] tags

  2. #2
    Sierra is offline AN21XX
    Join Date
    Mar 2012
    Location
    Munich
    Posts
    297
    Rep Power
    3

    Default Re: Making an Encoder

    What is the meaning of this? Try to comment your code sections...!

    Java Code:
          if(code){
            for(int index = 1; index < letters.length(); index++){
              if (index == 0){
                words += current;
                continue;
              }
            }
          }
    Problem here is that index will never get 0 at all and "continue" is not needed here at all... just my 2 cents - have not looked any further.
    I cannot get behind what you are trying to do...
    Last edited by Sierra; 04-20-2012 at 01:27 PM.

Similar Threads

  1. OGG Vorbis encoder (Moved)
    By bockymurphy in forum Reviews / Advertising
    Replies: 2
    Last Post: 12-13-2011, 07:25 PM
  2. OGG Vorbis encoder
    By povilasb in forum Advanced Java
    Replies: 1
    Last Post: 12-08-2011, 12:11 AM
  3. OGG Vorbis encoder
    By povilasb in forum New To Java
    Replies: 0
    Last Post: 01-19-2011, 09:42 PM
  4. image encoder decoder
    By fayiza in forum Java 2D
    Replies: 1
    Last Post: 09-19-2010, 06:55 PM
  5. Mp3 encoder
    By sniper99 in forum Advanced Java
    Replies: 3
    Last Post: 04-09-2009, 10:33 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
  •