How to use web services to realize automatic updating of weather reports on asp web pages
1. The first is the method class:
public class Method {
//The parameter is the input letter
public void printWeather(String inputChar)
{
//Judge based on the entered letters
if(inputChar.equalsIgnoreCase("d"))
{
System .out.println("dry");
}
if(inputChar.equalsIgnoreCase("m"))
{
System.out.println("moist");
}
if(inputChar.equalsIgnoreCase("h"))
{
System.out.println("hot");
}
if(inputChar.equalsIgnoreCase("r"))
{
p>
System.out.println("Raining");
}
else
{
System. out.println("Input error");
}
}
}
2.
The second is the execution class:
import java.util.*;
public class Test {
public static void main(String[] args) {
p>
Scanner input=new Scanner(System.in);
String weather="";
String answer="";
Method method=new Method();
do
{
System.out.println("Please enter the first letter (d,m,h, r)");
//Receive the input weather
weather=input.next();
//Call the method and pass in the parameters
p>
method.printWeather(weather);
System.out.println("Do you want to continue inputting?");
//Receive whether the input is n
answer=input.next();
}while(!answer.equalsIgnoreCase("n"));
}
}< /p>