最近中文字幕高清中文字幕无,亚洲欧美高清一区二区三区,一本色道无码道dvd在线观看 ,一个人看的www免费高清中文字幕

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

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

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

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)生隨機(jī)數(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]="強(qiáng)風(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è)置客戶端窗口的標(biāo)題 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); // 為連接按鈕注冊(cè)監(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貢獻(xiàn)4條經(jīng)驗(yàn) 獲得超2個(gè)贊

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

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

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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