Traditional Culture Encyclopedia - Weather inquiry - Java programming problems, to achieve a simple English-Chinese weather converter.
Java programming problems, to achieve a simple English-Chinese weather converter.
Public? Class? The weather? {
Public? Static electricity String? getWeatherInChinese(char? c)? {
Switch? (3)? {
Case? d ':
Return? "drying";
Case? m ':
Return? "wet"
Case? h ':
Return? "hot";
Case? r ':
Return? "rain"
Default value:
Return? "Input error, unable to convert";
}
}
Public? Static electricity Invalid? main(String[]? args)? {
Bull? Pending? =? True;
Do what? {
System.out.print ("Please enter the first English letter of the weather:");
Scanner? Scanner? =? New? Scanner (system. in);
String? Input? =? scanner.next()。 trim();
What if? (input.length()? ! =? 1)? {
System.out.println ("input error, unable to convert!" );
}? Or what? {
system . out . println(getWeatherInChinese(input . charat(0)));
}
System.out.print ("Do you want to continue? (y/n)");
String? sta? =? scanner . next();
Pending? =? Sta.equals("y "), right? :? Fake;
}? What time? (to be determined);
System.out.println ("Exit the system!" );
}
} Run the screenshot:
- Previous article:Why does the mood change with the weather?
- Next article:A collection of beautiful sentences describing rain
- Related articles
- Help me translate a few words of Japanese and mark them with Hiragana.
- Suihua1February 20-1February 26 weather forecast.
- How to get to daofu county, Ganzi Tibetan Autonomous Prefecture, Sichuan? ! !
- What is the working environment and salary of continental brand tires in Hefei?
- 202 1 fourth grade English summer homework answers for the next semester
- Sichuan traffic accident compensation standard: 20 1 1 August11day 12, my friend accidentally hit a pedestrian crossing the road in S305.
- Lyrics of "Fine Weather"
- Summer beauty salon greetings
- The accuracy of Guangzhou weather forecast 15 days is high.
- How does OPPO mobile phone display lunar calendar on the desktop?