I'm creating a program that reads in something written in Morse code and translates it to English, I first have to read in the first number for all the data sets the the second which stands for how much data is in the first data set, then i read in the String with which is th morse code. I decided to use a Switch statement for this program but everytime i complile it it says "incompatible types" for switch(morse). FYI This only apart off my code..
<pre>
import java.io.*;
import java.util.*;
import static java.lang.System.*;
public class G{
public static void main(String[] args)throws IOException
{
Scanner scan = new Scanner(new File("G.txt"));
int times = scan.nextInt();
times=scan.nextInt();
for(int i=0; i<times; i++){
String morse = scan.nextLine();
switch(morse){
case ".- ":
System.out.print( "a");
break;
case "-… ":
System.out.print( "b");
break;
case "-.-. ":
System.out.print( "c");
break;
}
}
}
<code>
This is my input file(ignore the spaces between each line) 2
4
-..
..-
-..
.
4
-..
.
.-..
.--.