China Naming Network - Ziwei Dou Shu - Java weather query
Java weather query
Import java.util.scanner;
Public class to Chinese {
Public static void main(String[] args) {
//Instantiate the scanner
Scanner sc = new scanner (system. in);
//Prompt the user for input
System.out.println ("Please enter the weather initials (d, m, r, S)");");
//receive
string weather = sc . next();
//Call the method to be converted.
String chinese=toCn (weather);
//output
System.out.print (Chinese);
}
//Method of converting Chinese
Public static string toCn (string weather)
{
//D stands for drying.
if(weather.equals("D "))
{
Return to "dry";
}
else if(weather.equals("M "))
{
Return to "wet";
}
else if(weather.equals("R "))
{
Return to Rainy Days;
}
else if(weather.equals("S "))
{
Return to Sunny Day;
}
other
{
Return "You entered it incorrectly!" ;
}
}
}