モールス信号を英語に、またはその逆に変換するための課題があります。モースを英語に変換するのに助けが必要ですが、それが疑わしいので、まだ学んでいないあまりにも洗練されたものを使うことはできません。
public class Project11
{
public static void main ( String [] args)
{
int a = Input.getInt ("1 for English or 2 for Morse Code");
String s1 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ 1234567890";
String[] Morse = {".- ","-... ","-.-. ","-.. ",". ","..-. ","--. ",".... ",".. ",".--- ","-.- ",".-.. ","-- ","-. ","--- ",".--. ","--.- ",".-. ",
"... ","- ","..- ","...- ",".-- ","-..-","-.-- ","--.. ","|",".--- ","..--- ","...-- ","....- ","..... ","-.... ","--... ","---.. ","----. ","----- "};
switch(a)
{
case 1:
English(s1, Morse);
break;
case 2:
Morse(s1, Morse);
break;
default:
System.out.println("You have typed an incorrect key, please run the program again.");
}
}
public static void English (String s1, String[] Morse)
{
String Phrase = Input.getString ("Type in the sentence to convert");
String convertphrase = Phrase.toUpperCase();
char[] a = convertphrase.toCharArray();
char[] s = s1.toCharArray();
int length = a.length;
for(int j = 0; j < length; j++)
{
for(int i = 0; i < 35; i++)
{
if(s[i] == a[j])
{
System.out.print(Morse[i]);
}
}
}
}
public static void Morse (String s1, String[] Morse)
{
String Phrase = Input.getString ("Type in the sentence to convert");
char[] a = Phrase.toCharArray();
int length = a.length;
}
}
これが私が持っているすべてです