第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何將天氣的數(shù)據(jù)寫到數(shù)據(jù)庫中,出行指數(shù)根據(jù)天氣的一些數(shù)據(jù)來進行判斷

如何將天氣的數(shù)據(jù)寫到數(shù)據(jù)庫中,出行指數(shù)根據(jù)天氣的一些數(shù)據(jù)來進行判斷

package wtpaly;import javax.swing.*;import java.awt.*;import java.awt.event.*;import java.net.*;public class Wtplay extends JFrame { //窗口配置 private JTextArea messageArea; private JButton send; //wt配置 private int tq;//天氣 晴40-2 ?陰60-2 雨0-3 private int wd;//溫度 高10-3 ?中15-1 ?低5-3 private int sd;//濕度 濕 5-4 ? 干10-3 private int fl;//風(fēng)力 無15-2 ?微10-3 ?大0-2 private String[] wt=new String[4]; //產(chǎn)生隨機數(shù) private int ?rad(){ int a=(int)(Math.random()*7); return a; } //產(chǎn)生天氣 public String randwt(){ int a=this.rad();//產(chǎn)生天氣 if(a<2){ this.tq=2; this.wt[0]="晴"; }else if(a<4){ this.tq=3; this.wt[0]="多云"; }else{ this.tq=0; this.wt[0]="雨"; } int b=this.rad();//產(chǎn)生溫度 if(b<1){ this.wd=1; this.wt[1]="低溫"; }else if(b<4){ this.wd=3; this.wt[1]="中等"; }else{ this.wd=2; this.wt[1]="高溫"; } int c=this.rad();//產(chǎn)生濕度 if(c<4){ this.sd=1; this.wt[2]="潮濕"; }else{ this.sd=2; this.wt[2]="干燥"; } int d=this.rad();//產(chǎn)生風(fēng)力 if(d<1){ this.fl=0; this.wt[3]="強風(fēng)"; }else if(d<4){ this.fl=3; this.wt[3]="無風(fēng)"; }else{ this.fl=2; this.wt[3]="微風(fēng)"; } String af="天氣:"+this.wt[0]+"\n溫度:"+this.wt[1]+"\n濕度:"+this.wt[2]+"\n風(fēng)力:"+this.wt[3]+"\n出行指數(shù):"+(this.tq*20+this.wd*5+this.sd*5+this.fl*5); return af; } class ButtonListener implements ActionListener { public void actionPerformed(ActionEvent e) { if (e.getSource() == send) { String a=new Wtplay().randwt(); messageArea.setText(a); } } } public Wtplay() { // 設(shè)置客戶端窗口的標題 super("Wtpllay"); // 初始化界面元素 messageArea = new JTextArea(); send = new JButton("明天"); // 設(shè)置界面布局 Container c = this.getContentPane(); JScrollPane jsp = new JScrollPane(messageArea); c.add(jsp); JPanel jp = new JPanel(); jp.add(send); c.add(jp, BorderLayout.SOUTH); // 為連接按鈕注冊監(jiān)聽器 P74 ButtonListener bl = new ButtonListener(); send.addActionListener(bl); } public static void main(String[] args) { Wtplay Wtplay = new Wtplay(); Wtplay.setSize(500, 300); Wtplay.setLocation(200, 200); Wtplay.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Wtplay.setVisible(true); String a=Wtplay.randwt(); Wtplay.messageArea.setText(a); }}
查看完整描述

1 回答

?
yxs1112003

TA貢獻4條經(jīng)驗 獲得超2個贊

這類問題用python實現(xiàn)是最簡單的,打開一個天氣網(wǎng)站連接,根據(jù)它的api規(guī)定發(fā)送一個請求,獲取返回關(guān)于天氣的的json數(shù)據(jù),根據(jù)json內(nèi)容輸出出行指數(shù)。和數(shù)據(jù)庫毫無關(guān)系

查看完整回答
反對 回復(fù) 2016-06-25
  • 1 回答
  • 0 關(guān)注
  • 1863 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號