设计一个小英汉词典,其中英文单词的个数为30(单词可自己任选),从键盘输入单词,程序将单词的中文解释输出,若没有找到,则输出:not found in our dictionary!

Posted Pistachiout

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了设计一个小英汉词典,其中英文单词的个数为30(单词可自己任选),从键盘输入单词,程序将单词的中文解释输出,若没有找到,则输出:not found in our dictionary!相关的知识,希望对你有一定的参考价值。

设计一个小英汉词典,其中英文单词的个数为30(单词可自己任选),编程序,从键盘输入单词,程序将单词的中文解释输出,若没有找到,则输出:not found in our dictionary!

//import java.io.*;
import java.util.*;
//import java.util.Scanner;
public class UseOfDictionary 

	public static void main(String[] args) 
		// TODO Auto-generated method stub
		String[] englishWords=new String[]"computer","university","people","student","economics","me","our","so","import","implments","interface","final","public","dictionary","english","chinses","simple","social","why","difficult","simple","close","beautiful","omit","adequate","circumstance","abolish","vacant","reluctant","excessive";
		String[] chineseTranslation=new String[]"n.计算机","n.综合性大学","n.人们、人民","n.大学生","n.经济学","n.我","n.我们的","n.所以","n.传入;引入","n.实施;执行;实现","与…连接;接合","最后的;","公众的","词典","英语","中文","简单的","社会的","为什么","困难的","简单的","近的","漂亮的","遗漏","充足的","情况","废除","空闲的","不情愿的","过多的";
		Map<String,String> dictionary=new TreeMap<String,String>();
		for(int i=0;i<englishWords.length;i++)
			dictionary.put(englishWords[i], chineseTranslation[i]);
		System.out.println("请从键盘上输入你想要翻译的单词:");
		Scanner input=new Scanner(System.in);
		String userword=input.next();//输入数据
		if(dictionary.get(userword)!=null)
		
			System.out.println(dictionary.get(userword));
		
		else 
			System.out.println("not found in our dictionary!");
		
	


以上是关于设计一个小英汉词典,其中英文单词的个数为30(单词可自己任选),从键盘输入单词,程序将单词的中文解释输出,若没有找到,则输出:not found in our dictionary!的主要内容,如果未能解决你的问题,请参考以下文章

普歌-C语言实现英汉电子词典

LRF-C语言实现英汉电子词典

2018-10-30 浏览器插件-离线英汉词典 0.0.7

钻石英语怎么说

php+mysql实现英汉查询词典的功能

分享自己做的一个词典小软件