Binary Converter
in
Programming Questions
•
1 year ago
I'm trying to make a program where I can type something in binary, and it will convert it into letters for me. I came up with this simple program, but it's telling me the "[" in the third line is unexpected. What did I do wrong?
- String letters[]=new String[26];
- String typed="0";
- letters[0]="a";
- letters[1]="b";
- letters[2]="c";
- letters[3]="d";
- letters[4]="e";
- letters[5]="f";
- letters[6]="g";
- letters[7]="h";
- letters[8]="i";
- letters[9]="j";
- letters[10]="k";
- letters[11]="l";
- letters[12]="m";
- letters[13]="n";
- letters[14]="o";
- letters[15]="p";
- letters[16]="q";
- letters[17]="r";
- letters[18]="s";
- letters[19]="t";
- letters[20]="u";
- letters[21]="v";
- letters[22]="w";
- letters[23]="x";
- letters[24]="y";
- letters[25]="z";
- void draw(){
- text(unbinary(typed),10,10);
- }
- void keyReleased(){
- if(key!=CODED){
- switch(key){
- case BACKSPACE:
- typed=typed.substring(0,max(0,typed.length()-1));
- break;
- default:
- typed+=key;
- }
- }
- }
1