2016-08-04 17 views
-2

私はかなりJava初心者ですが、いくつかの基本単位変換を行うプログラムを書いています。ここで私はこれまで持っているものです。シンボルエラーが見つかりませんでした。

class Assignment8 
{ 
public static void main(String[]args) 
{ 
    System.out.println("1. US Measurment to Metric" + "\n" + "2. Metric to US Measurement"); 
    int us_or_metric = Input.getInt ("Please enter the desired convertion"); 
    switch (us_or_metric) 
    { 
     case 1: 
      System.out.println("\n" + "1. Pound to Kilogram" + "\n" + "2. Ounce to Gram" + "\n" + "3. Foot to Meter" + "\n" + "4. Mile to Kilometer"); 
      int us_conversions = Input.getInt("Please enter the desired convertion"); 
      switch (us_conversions) 
      { 
       case 1: 
        double a = Input.getDouble("Please enter amount to be converted"); 
        double b = 0.4536D; 
        System.out.println(a + "pound(s) is" + pound(a,b) + "kilogram(s)"); 
        break; 
       case 2: 
        double c = Input.getDouble ("Please enter amount to be converted"); 
        double d = 28.5D; 
        System.out.println(c + "ounce(s) is" + ounce(c,d) + "gram(s)"); 
        break; 
       case 3: 
        double e = Input.getDouble ("Please enter amount to be converted"); 
        double f = 0.3048D; 
        System.out.println(e + "feet is" + foot(e,f) + "meter(s)"); 
        break; 
       case 4: 
        double g = Input.getDouble ("Please enter amount to be converted"); 
        double h = 1.61D; 
        System.out.println(g + "mile(s) is" + mile(g,h) + "kilometer(s)"); 
        break; 
      } 
      break; 
     case 2: 
      System.out.println("\n" + "1. Kilogram to Pound" + "\n" + "2. Gram to Ounce" + "\n" + "3. Meter to Foot" + "\n" + "4. Kilometer to Mile"); 
      int metric_conversions = Input.getInt ("Please enter the desired convertion"); 
      switch (us_conversions) 
      { 
       case 1: 
        double i = Input.getDouble("Please enter amount to be converted"); 
        double j = 2.2046D; 
        System.out.println(i + "kilogram(s) is" + kilogram(i,j) + "pound(s)"); 
        break; 
       case 2: 
        double k = Input.getDouble ("Please enter amount to be converted"); 
        double l = 0.0352D; 
        System.out.println(k + "gram(s) is" + gram(k,l) + "ounce(s)"); 
        break; 
       case 3: 
        double m = Input.getDouble ("Please enter amount to be converted"); 
        double n = 3.2808D; 
        System.out.println(m + "meter(s) is" + meter(m,n) + "feet"); 
        break; 
       case 4: 
        double o = Input.getDouble ("Please enter amount to be converted"); 
        double p = 0.6213D; 
        System.out.println(o + "kilometer(s) is" + kilometer(o,p) + "mile(s)"); 
        break; 
      } 
      break; 
    } 
} 

public static double pound(double a , double b) 
{ 
    return a * b; 
} 


public static double ounce(double c , double d) 
{ 
    return c * d; 
} 

public static double foot(double e, double f) 
{ 
    return e * f; 
} 

public static double mile(double g , double h) 
{ 
    return g * h; 
} 
public static double kilogram(double i , double j) 
{ 
    return i * j; 
} 
public static double gram(double k , double l) 
{ 
    return k * l; 
} 
public static double meter(double m , double n) 
{ 
    return m * n; 
} 
public static double kilometer(double o , double p) 
{ 
    return o * p; 
} 

}

私はシンボルエラーを見つけることができません取得、それをコンパイルするために行きます。私はここでこのページを見てきました What does a "Cannot find symbol" compilation error mean? 私は自分の問題を特定できません。誰かがエラーを見つけるのを助けることができますか?申し訳ありませんが、それは明らかなものですが、私はまだコーディングnoobです。 Iveはコンパイルして実行するプログラムを取得しましたが、特定の場所、つまりデスクトップ上にjavaというフォルダがあります。これがなぜ起こるのかについてのアイデアは何ですか?


Compilation errors

Compilation error time: 0 memory: 0 signal:0 
Main.java:13: error: cannot find symbol 
    int us_or_metric = Input.getInt ("Please enter the desired convertion"); 
        ^
    symbol: variable Input 
    location: class Assignment8 
Main.java:18: error: cannot find symbol 
      int us_conversions = Input.getInt("Please enter the desired convertion"); 
           ^
    symbol: variable Input 
    location: class Assignment8 
Main.java:22: error: cannot find symbol 
        double a = Input.getDouble("Please enter amount to be converted"); 
          ^
    symbol: variable Input 
    location: class Assignment8 
Main.java:27: error: cannot find symbol 
        double c = Input.getDouble ("Please enter amount to be converted"); 
          ^
    symbol: variable Input 
    location: class Assignment8 
Main.java:32: error: cannot find symbol 
        double e = Input.getDouble ("Please enter amount to be converted"); 
          ^
    symbol: variable Input 
    location: class Assignment8 
Main.java:37: error: cannot find symbol 
        double g = Input.getDouble ("Please enter amount to be converted"); 
          ^
    symbol: variable Input 
    location: class Assignment8 
Main.java:45: error: cannot find symbol 
      int metric_conversions = Input.getInt ("Please enter the desired convertion"); 
            ^
    symbol: variable Input 
    location: class Assignment8 
Main.java:49: error: cannot find symbol 
        double i = Input.getDouble("Please enter amount to be converted"); 
          ^
    symbol: variable Input 
    location: class Assignment8 
Main.java:54: error: cannot find symbol 
        double k = Input.getDouble ("Please enter amount to be converted"); 
          ^
    symbol: variable Input 
    location: class Assignment8 
Main.java:59: error: cannot find symbol 
        double m = Input.getDouble ("Please enter amount to be converted"); 
          ^
    symbol: variable Input 
    location: class Assignment8 
Main.java:64: error: cannot find symbol 
        double o = Input.getDouble ("Please enter amount to be converted"); 
          ^
    symbol: variable Input 
    location: class Assignment8 
11 errors 
+0

もAssignment8.mile' –

+0

'とmile''のようにすべてのコードを交換してください(これはimperial_conversionsに名前を変更しなければならない)、それはあなたのEclipseやIntelliJのようなIDEを使用するには、長い長い道のりを助ける –

+0

することはできませんWHICHシンボルを見つける。あなたの投稿を編集して、あなたが得たエラーメッセージを追加してください(コピー/ペーストしてから4つのスペースをインデントしてください) –

答えて

0

エラーメッセージが何を言いましたの?

us_conversionsが範囲外のときに使用しようとしています。

case 2: 
      System.out.println("\n" + "1. Kilogram to Pound" + "\n" + "2. Gram to Ounce" + "\n" + "3. Meter to Foot" + "\n" + "4. Kilometer to Mile"); 
      int metric_conversions = Input.getInt ("Please enter the desired convertion"); 
      switch (us_conversions) // <-- Here is your problem, change to metric_conversions 
      { 
       case 1: 
関連する問題