Created
January 13, 2019 17:37
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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