Skip to content

Instantly share code, notes, and snippets.

@MrOnlineCoder
Created January 13, 2019 17:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MrOnlineCoder/898337f7cff3def2bf9b510bfc64ac73 to your computer and use it in GitHub Desktop.
Save MrOnlineCoder/898337f7cff3def2bf9b510bfc64ac73 to your computer and use it in GitHub Desktop.
This is a post by one guy from Russian forum. The task is to make a simple translator in Java: there is a map which maps translations and you enter the sentence and get all words replaced by their translations respectively. Very funny solution.
/*
Original: http://www.cyberforum.ru/java-j2se/thread1016035.html#post13221448
*/
import javax.swing.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Translator {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Введите погоду и получите перевод: ");
String s = reader.readLine();
String v = " ";
if(s.equals("rain")||s.equals("дождь")){
v="дождь";
v="rain";
}
else if(s.equals("snow")||s.equals("снег")){
v="снег";
v="snow";
}
else if(s.equals("sun")||s.equals("солнце")){
v="солнце";
v="sun";
}
else if(s.equals("fog")||s.equals("туман")){
v="туман";
v="fog";
}
else if(s.equals("storm")||s.equals("шторм")){
v="шторм";
v="storm";
}
else if(s.equals("cold")||s.equals("холодно")){
v="холодно";
v="cold";
}
else if(s.equals("hot")||s.equals("жарко")){
v="жарко";
v="hot";
}
else{
System.out.println("нет");
}
System.out.println(v);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment