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.

Import? Java . util . scanner;

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: