UVA 12250 – Language Detection

I missed the switch statements in Java 7 that can take in Strings as cases for this question. Pretty easy.

import java.io.PrintWriter;
import java.util.Scanner;

/**
 * 
 * @author Sanchit M. Bhatnagar
 * @see http://uhunt.felix-halim.net/id/74004
 * 
 */
public class P12250 {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    PrintWriter out = new PrintWriter(System.out);

    int i = 1;
    String line;
    while ((line = sc.nextLine()) != null) {
      line = line.trim();
      if (line.equals("#"))
        break;
      out.print("Case " + i + ": ");
      if (line.equals("HELLO")) {
        out.println("ENGLISH");
      } else if (line.equals("HOLA")) {
        out.println("SPANISH");
      } else if (line.equals("HALLO")) {
        out.println("GERMAN");
      } else if (line.equals("BONJOUR")) {
        out.println("FRENCH");
      } else if (line.equals("CIAO")) {
        out.println("ITALIAN");
      } else if (line.equals("ZDRAVSTVUJTE")) {
        out.println("RUSSIAN");
      } else {
        out.println("UNKNOWN");
      }
      i++;
    }
    out.close();
    sc.close();
  }
}

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.