第十六次Java作业

 

点击控制管理台

复制对应的易源数据-全国天气预报查询中的Appcode,并且点击左上角的蓝色标记易源数据-全国天气预报查询.

进入页面之后:

点击查询24小时预报

调试地址是该服务器的接口,直接点击调试工具中的去调试.

 将aera 名丽江改为北京然后再点击发送请求.

得出结果:

 

 

 

 

 

 

 

 

import java.util.Scanner;
public class Application {
public static void main(string[] args) {
System.out.println("查询最近天气预报:");
System.out.println("输入1:查询未来24小时天气预报"); 
System.out.println("输入2:查询未来3天天气预报");
 System.out.println("输入3:查询未来7天天气预报");
 System.out.println("请输入您的选择:");
Scanner scanner = new Scanner(System.in); 
int i = scanner.nextint();
System.out.println("用户输入数字:"+i);
}
}

 

 

 

 

 

 

 

 

 

 

 

public static void main(string[] args){
System.out.println("查询最近天气预报:");
System.out.println("输入1:查询未来24小时天气预报");
 System.out.println("输入2:查询未来3天天气预报");
 System.out.println("输入3:查询未来7天天气预报"); 
System.out.print("请输入您的选择:");
Scanner scanner=newScanner(System.in); 
int i=scanner.nextInt();
System.out.println("用户输入数字:"+i);
 if(i==1){
System.out.print("请输入城市名称查询未来24小时天气预报:");
 String city=scanner.next();
WeatherUtils weatherUtils=new WeatherUtilsTmpl):
List<HourWeather> weatherList=weatherUtils.w24h(anpCode"79da35b1a1bC
System.out.println(weatherList); 
if(weatherList.size()==0){
System.out:println("抱歉,未收录您查询的城市天气数据。");
}else{
for HourWeather hourWeather:weatherList){
String template="8s月8s日8s时18S|8S|8S|8S℃";
String row=String.format(templatenew String[]{
hourWeather.getMonth(),
 hourWeather.getDay(), 
hourWeather.getHour(),
hourWeather.getWindDirection(),
 hourWeather.qetWindPower()
hourWeather.getWeather(),
hourWeather.getTemperature()});
System.out.println(row);}

 

 

 在数字3面前加以-号,使文字左对齐;

 查询未来三天代码段,接上面代码:

 for(DayWeather weather:weatherList){
String template="8-2s月8-2s日|气温:S℃(日)s℃(夜) 天气:8S string row=string.format(template,new string[]{
weather.getMonth(), weather.getDay(),
weather.getDayAirTemperature(), weather.getNightAirTemperature() weather.getDayWeather(), weather.qetNightWeather(), weather.qetDayWindPower(), weather.getNightWindPower ()
});
System.out.println(row);}

 运行结果;

查询未来七天天气预报结果:

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值