Re: [問題]java新手 java.io 無法執行?

看板java作者 (***********先生)時間7年前 (2017/07/26 19:45), 7年前編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/2 (看更多)
我想這大概是你要的功能吧?但我不知道你看的是甚麼網頁教學只能看你打出來的 code做更改。 import java.util.Scanner; package pratice; public class prac_ch03 public static void main(String [] args){ Scanner scanner = new Scanner(System.in); float height; float weight; System.out.println("Please input your height:"); height = scanner.nextFloat(); System.out.println("Please input your weight:"); weight = scanner.nextFloat(); System.out.println("Your BMI is :" + weight/(height*height)); } } ※ 引述《ProGramE (SP_one)》之銘言: : 我是在 Eclipse 編輯 使用 java.io 卻發生問題 直接複製網路上的教學也是無法執行? : 以下是我所編譯的 : package pratice; : import java.io.*; : public class prac_ch03 : { : public static void main(String args[])throws IOException : { : float height; : float weight; : System.out.println("Please input your height."); : height = keyin.readLine(); : System.out.println("Please input your weight."); : weight = keyin.readLine(); : System.out.println("Your BMI is :" + weight/(height*height)); : } : } : 執行出現: : Exception in thread "main" java.lang.Error: Unresolved compilation problems: : keyin cannot be resolved : keyin cannot be resolved : at pratice.prac_ch03.main(prac_ch03.java:13) : 請問是我忽略甚麼步驟以至於如此嗎? : 在網路上尋找都找不到解答 : 麻煩各位! -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 60.250.250.131 ※ 文章網址: https://www.ptt.cc/bbs/java/M.1501069554.A.721.html ※ 編輯: mmxmmxmmx (60.250.250.131), 07/26/2017 19:46:32 ※ 編輯: mmxmmxmmx (60.250.250.131), 07/26/2017 19:46:48
文章代碼(AID): #1PU83oSX (java)
文章代碼(AID): #1PU83oSX (java)