package student; import java.util.HashMap; import java.util.Scanner; public class Test1 { public static void main(String[] args) { HashMap<String, String> hm=new HashMap<String, String>(); hm.put("banana" , "香蕉"); hm.put("apple" , "苹果"); hm.put("orange" , "橘子"); hm.put("pear" , "梨"); hm.put("cat" , "猫"); Scanner sc=new Scanner(System.in); while (true){ System.out.println("请输入你要翻译的单词:"); String word= sc.next(); if(!hm.containsKey(word)){ System.out.println("您输入的单词有误!!!请重新输入:"); }else { String chinese=hm.get(word); System.out.println(word+"的中文翻译是:"+chinese); } } } }
模仿百度翻译案例
最新推荐文章于 2024-11-04 20:33:37 发布