Results 1 to 2 of 2
Thread: Making an Encoder
- 04-19-2012, 09:05 PM #1
Member
- Join Date
- Mar 2012
- Posts
- 9
- Rep Power
- 0
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 09:38 PM. Reason: added [code] ... [/code] tags
- 04-20-2012, 12:24 PM #2
AN21XX
- Join Date
- Mar 2012
- Location
- Munich
- Posts
- 297
- Rep Power
- 2
Re: Making an Encoder
What is the meaning of this? Try to comment your code sections...!
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.Java Code:if(code){ for(int index = 1; index < letters.length(); index++){ if (index == 0){ words += current; continue; } } }
I cannot get behind what you are trying to do...Last edited by Sierra; 04-20-2012 at 12:27 PM.
Similar Threads
-
OGG Vorbis encoder (Moved)
By bockymurphy in forum Reviews / AdvertisingReplies: 2Last Post: 12-13-2011, 06:25 PM -
OGG Vorbis encoder
By povilasb in forum Advanced JavaReplies: 1Last Post: 12-07-2011, 11:11 PM -
OGG Vorbis encoder
By povilasb in forum New To JavaReplies: 0Last Post: 01-19-2011, 08:42 PM -
image encoder decoder
By fayiza in forum Java 2DReplies: 1Last Post: 09-19-2010, 05:55 PM -
Mp3 encoder
By sniper99 in forum Advanced JavaReplies: 3Last Post: 04-09-2009, 09:33 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks