How do i make java read the spaces?

Custom encoding

wormhole
12 years ago

0

i worte this so far.. only problem is that the spaces do not work. Is it possible to change the value for blankspace in java? I place the crypted message in the “int[] tal ={}” of course..

public class skrivurt {

public static void main(String args[]) {

int[] tal = {};  
 skriv(tal[0]);  

skriv(tal[1]);
skriv(tal[2]);
skriv(tal[3]);
skriv(tal[4]);
skriv(tal[5]);
skriv(tal[6]);
skriv(tal[7]);
skriv(tal[8]);
skriv(tal[9]);
skriv(tal[10]);
skriv(tal[11]);
skriv(tal[12]);
skriv(tal[13]);
skriv(tal[14]);
skriv(tal[15]);
skriv(tal[16]);
skriv(tal[17]);
skriv(tal[18]);
skriv(tal[19]);
skriv(tal[20]);
skriv(tal[21]);
skriv(tal[22]);
skriv(tal[23]);
skriv(tal[24]);
skriv(tal[25]);
skriv(tal[26]);
skriv(tal[27]);
skriv(tal[28]);
skriv(tal[29]);
skriv(tal[30]);
skriv(tal[31]);
skriv(tal[32]);
skriv(tal[33]);
skriv(tal[34]);
skriv(tal[35]);
skriv(tal[36]);
skriv(tal[37]);
skriv(tal[38]);
skriv(tal[39]);
skriv(tal[40]);
skriv(tal[41]);
skriv(tal[42]);
skriv(tal[43]);
skriv(tal[44]);
skriv(tal[45]);
skriv(tal[46]);
skriv(tal[47]);
skriv(tal[48]);
skriv(tal[49]);

 }  

static void skriv(int tal){
if (tal==61){
System.out.print(“a”);
}
else if (tal==60){
System.out.print(“b”);
}
else if (tal==59){
System.out.print(“c”);
}
else if (tal==58){
System.out.print(“d”);
}
else if (tal==57){
System.out.print(“e”);
}
else if (tal==56){
System.out.print(“f”);
}
else if (tal==55){
System.out.print(“g”);
}
else if (tal==54){
System.out.print(“h”);
}
else if (tal==53){
System.out.print(“i”);
}
else if (tal==52){
System.out.print(“j”);
}
else if (tal==51){
System.out.print(“k”);
}
else if (tal==50){
System.out.print(“l”);
}
else if (tal==49){
System.out.print(“m”);
}
else if (tal==48){
System.out.print(“n”);
}
else if (tal==47){
System.out.print(“o”);
}
else if (tal==46){
System.out.print(“p”);
}
else if (tal==45){
System.out.print(“q”);
}
else if (tal==44){
System.out.print(“r”);
}
else if (tal==43){
System.out.print(“s”);
}
else if (tal==42){
System.out.print(“t”);
}
else if (tal==41){
System.out.print(“u”);
}
else if (tal==40){
System.out.print(“v”);
}
else if (tal==39){
System.out.print(“v”);
}
else if (tal==38){
System.out.print(“w”);
}
else if (tal==37){
System.out.print(“x”);
}
else if (tal==36){
System.out.println(“y”);
}
else if (tal==35){
System.out.println(“z”);
}

else{  
   System.out.print(" ");  

}

}

}

10replies
7voices
251views
daMage
12 years ago

0

you want to change the space to something else? maybe to it’s ascii code?

Luke [flabbyrabbit]
12 years ago

0

I would also suggest having a quick look at loops, it would make things a bit easier.

daMage
12 years ago

0

yea, what flabby said :D

dalou
12 years ago

0

Wayyyy to much code!!!! I still can’t believe how useful loops are!

J [ColdIV]
12 years ago

0

By the way, for this level you could also use C# or something like this I think that’s also a easy way :)
Worked nice for me

dalou
11 years ago

0

Javascript is nice cause you don’t have to compile.

Luke [flabbyrabbit]
11 years ago

0

The nicer aspect of Javascript in relation to these levels is the fact that you can run it in the browser. Directly interacting with the loaded page. You can shave seconds off your time by getting Javascript to add the answer to and submit the form automatically.

J [ColdIV]
11 years ago

0

Of course it’s easier in JavaScript and you don’t have to compile it.
But the nice thing about a C# program is that you can use it as long as you want and I guess when you really want to use such a method then you probably want a stable program to do it for you.
And you can auto-copy the output of the program so time won’t be any problem..

BLACK OPS [Noob13]
11 years ago

0

Thankx ur code help me ( VB ), and you need change
39 = w, 37 = y

wence
11 years ago

0

To Find it’s a WhiteSpace use Character.isWhitespace(codePointValue);

Holy Smoke ~~~ In C i can write better program …….. In Java Much Better so i can do App . In order to transfer from char to int(ASCII) and later ASCII to char … I use Casting in Java If i really wanted to or else I ask Java to do for me.

You must be logged in to reply to this discussion. Login
1 of 11

This site only uses cookies that are essential for the functionality of this website. Cookies are not used for tracking or marketing purposes.

By using our site, you acknowledge that you have read and understand our Privacy Policy, and Terms of Service.

Dismiss