Traditional Culture Encyclopedia - Weather forecast - Java语言(一种计算机语言,尤用于创建网站)定义一个带参数方法,输入英文单词的第一个字母实现一个简单的英中天气转换器
Java语言(一种计算机语言,尤用于创建网站)定义一个带参数方法,输入英文单词的第一个字母实现一个简单的英中天气转换器
导入Java . util . scanner;公共类ToChinese {
公共静态void main(String[] args) {
//实例化出一个扫描器
Scanner sc =新扫描仪(system . in);
//提示用户输入
System.out.println("请输入天气首字母(D,M,R,S)");
//接收
字符串weather = sc . next();
//调用方法,转换
String chinese=toCn(天气);
//输出
System.out.print(中文);}
//转换中文的方法公共静态字符串toCn(字符串天气)代表干燥if(weather.equals("D "))干燥";}
否则if(weather . equals(" M "))
{
return "潮湿";}
else if(weather . equals(" R ")
{
return "雨天";}
else if(weather . equals(" S ")
{
return "晴天";}
否则{
return "您的输入有误!";
}
}
}
- Previous article:Deyang Two-Day Tour Recommendation-Route Planning and Ticket Price
- Next article:What do you need to buy in hot weather?
- Related articles
- How do bees feed bees every few days in winter?
- What kind of tea does Pu 'er tea belong to?
- The weather stung my heart.
- I plan to travel to Gansu in July. Is July suitable for traveling to Gansu? Is it windy and dusty in July?
- How to pronounce degree in English?
- How many seas are there in Fangchenggang? What are their names? How to get to the seaside after taking the bus to Fangchenggang?
- The meaning, explanation and origin of spring cold.
- March Russian travel guide March Russian travel guide
- Causes of hot season in South Asia
- The weather in Liu Qi area