私は現在、双方向モールス符号翻訳プログラムに取り組んでいます。まだ完成していませんが、プログラムのテストを行っているときに、複数のコンパイル エラーが発生しました。何が悪いのかわかりませんが、単純なことだと確信しています。どんな助けでも大歓迎です。
これまでの私のコードは次のとおりです。
public class MorseCodeProject
{
public static void main(String[] args)
{
System.out.println("Please enter the conversion to be preformed.");
System.out.println("Type 1 to convert English to Morse code.");
System.out.println("Type 2 to convert Morse code to English.");
int type = Input.getInt();
System.out.println("Please enter the message to be converted.");
String message = Input.getString();
if(type == 1)
EtoM(message);
else
MtoE(message);
}
public static void EtoM(String message)
{
String translation[] = new String[message.length()];
String y;
for(int x = 0; x < message.length(); x++)
{
y = message.substring(x, x + 1);
switch(y)
{
case "a":
translation[x] = ".-";
break;
case "b":
translation[x] = "-...";
break;
case "c":
translation[x] = "-.-.";
break;
case "d":
translation[x] = "-..";
break;
case "e":
translation[x] = ".";
break;
case "f":
translation[x] = "..-.";
break;
case "g":
translation[x] = "--.";
break;
case "h":
translation[x] = "....";
break;
case "i":
translation[x] = "..";
break;
case "j":
translation[x] = ".---";
break;
case "k":
translation[x] = "-.-";
break;
case "l":
translation[x] = ".-..";
break;
case "m":
translation[x] = "--";
break;
case "n":
translation[x] = "-.";
break;
case "o":
translation[x] = "---";
break;
case "p":
translation[x] = ".--.";
break;
case "q":
translation[x] = "--.-";
break;
case "r":
translation[x] = ".-.";
break;
case "s":
translation[x] = "...";
break;
case "t":
translation[x] = "-";
break;
case "u":
translation[x] = "..-";
break;
case "v":
translation[x] = "...-";
break;
case "w":
translation[x] = ".--";
break;
case "x":
translation[x] = "-..-";
break;
case "y":
translation[x] = "-.--";
break;
case "z":
translation[x] = "--..";
break;
case "1":
translation[x] = ".----";
break;
case "2":
translation[x] = "..---";
break;
case "3":
translation[x] = "...--";
break;
case "4":
translation[x] = "....-";
break;
case "5":
translation[x] = ".....";
break;
case "6":
translation[x] = "-....";
break;
case "7":
translation[x] = "--...";
break;
case "8":
translation[x] = "---..";
break;
case "9":
translation[x] = "----.";
break;
case "0":
translation[x] = "-----";
break;
case " ":
translation[x] = "|";
default:
break;
}
for(int z = 0; z < message.length(); z++)
{
System.out.println(translation[z]);
}
}
}
public static void MtoE(String message)
{
int segments = 1;
char segment1;
int x = 0;
for(x = 0; x < message.length(); x++);
{
if(message.charAt(x) = "|")
{
segments += 1;
}
}
String segmentedMessage[] = new String[segments];
int j = 0;
int k;
for(int y = 0; y < segments; y++)
{
for(k = j; k < message.length(); k++)
{
if(message.charAt(k) == "|")
{
segementedMessage[y] = message.substirng(j, k);
j = k;
}
}
}
String segment;
String translation[] = new String[segments]
for(int c = 0; c < segments; c++)
{
segment = segmentedMessage[c];
switch(segment)
{
case ".-":
translation[c] = "a";
break;
case "-...":
translation[c] = "b";
break;
case "-.-.":
translation[c] = "c";
break;
case "-..":
translation[c] = "d";
break;
case ".":
translation[c] = "e";
break;
case "..-.":
translation[c] = "f";
break;
case "--.":
translation[c] = "g";
break;
case "....":
translation[c] = "h";
break;
case "..":
translation[c] = "i";
break;
case ".---":
translation[c] = "j";
break;
case "-.-":
translation[c] = "k";
break;
case ".-..":
translation[c] = "l";
break;
case "--":
translation[c] = "m";
break;
case "-.":
translation[c] = "n";
break;
case "---":
translation[c] = "o";
break;
case ".--.":
translation[c] = "p";
break;
case "--.-":
translation[c] = "q";
break;
case ".-.":
translation[c] = "r";
break;
case "...":
translation[c] = "s";
break;
case "-":
translation[c] = "t";
break;
case "..-":
translation[c] = "u";
break;
case "...-":
translation[c] = "v";
break;
case ".--":
translation[c] = "w";
break;
case "-..-":
translation[c] = "x";
break;
case "y-.--:
translation[c] = "y";
break;
case "--..":
translation[c] = "z";
break;
case ".----":
translation[c] = ".----";
break;
case "..--":
translation[c] = "..---";
break;
case "...--":
translation[c] = "...--";
break;
case "....-":
translation[c] = "....-";
break;
case ".....":
translation[c] = ".....";
break;
case "-....":
translation[c] = "-....";
break;
case "--...":
translation[c] = "--...";
break;
case "---..":
translation[c] = "---..";
break;
case "----.":
translation[c] = "----.";
break;
case "-----":
translation[c] = "-----";
break;
case "|":
translation[c] = " ";
default:
break;
}
}
}
}