作者ayaniji ( ̄▽ ̄b)
看板java
標題[問題] 請教一下
時間Thu Oct 16 02:27:04 2014
不好意思~請問關於下面的程式一些問題
--------------------------------------
//呼叫util套件
import java.util.*;
public class bmi {
public static void main(String[]args)throws java.io.IOException
{
//宣告區域變數 體重w為常數 bmi和身高為變數
int w=0;
double bmi=0,h=0;
//建立Scanner物件
Scanner sc=new Scanner(System.in);
System.out.print("請輸入體重");
w=sc.nextInt();
System.out.print("請輸入身高");
h=sc.nextInt();
//mbi公式
h=h/100;
h=h*h;
bmi=w/h;
//列印結果並顯示與螢幕上
System.out.println("bmi="+bmi);
}
}
----------------------------------------------
1.public static void main(String[]args)後面的throws java.io.IOException
2.Scanner sc=new Scanner(System.in)
3.w=sc.nextInt();
想請教上面幾個語法的用法意思
麻煩指點一下新手~謝謝Orz
--
自分を幸せにできるのは自分だけだから。
楽しくなければ生きている意味が無いし!
╭/\☆────/\╮ ╭/\─────/\╮│ │ │ \ / │
│ 喵 喵 │ │ 喵 喵 │
│○ ╰───╯ ○│ │〃 ╰┬┬┬╯ 〃│ │ │ ╰─╯ │
╰─┬O───O┬─╯ ╰─┬○───○┬─╯
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 118.167.154.68
※ 文章網址: http://www.ptt.cc/bbs/java/M.1413397627.A.1FA.html
→ fireslayer: 你應該先google 10/16 02:59
推 fireslayer: key word: Scanner , Exception Handling 10/16 03:03
推 LPH66: 你這段程式碼哪裡看來的, 去那個地方找一定有解說 10/16 04:05