2016-04-22 21 views
0
import java.util.Scanner; 
package reviewDistance; 

public class ReviewDistance { 

    public static void main(String[] args) { 
     int sec1; 
     int sec2; 
     int sec3; 
     int race; 
     Scanner input = new Scanner(System.in); 

     System.out.print("Enter the length of the first section of the race in kilometers:"); 
     sec1 = input.nextInt(); 
     System.out.print("Enter the length of the second section of the race in kilometers:"); 
     sec2 = input.nextInt(); 
     System.out.print("Enter the length of the third section of the race in kilometers:");; 
     sec3 = input.nextInt(); 
     input.close(); 

     race = sec1 + sec2 + sec3; 
     System.out.println("Length of the race: " + race + "km"); 

    } 

} 

我收到的錯誤代碼是這個,我不知道爲什麼!我很新到Java螺紋我使用eclipse,並得到這個錯誤有人可以告訴我,我哪裏出錯

異常 「主要」 java.lang.Error的:未解決的問題,編譯:

at reviewDistance.ReviewDistance.main(ReviewDistance.java:6) 
+0

在文件頂部的「進口」之前移動「包裝」:) – paulsm4

回答

0
import java.util.Scanner; 
package reviewDistance; 

將其更改爲

package reviewDistance; 
import java.util.Scanner; 

包應該是在你的檔案文件的第一行

+0

我覺得很sil現在:P但它的一切都是關於學習的權利? :P非常感謝你! – Chase

+0

很高興幫助:P –

相關問題