【问题标题】:I need help figuring out what is wrong with my code我需要帮助找出我的代码出了什么问题
【发布时间】:2015-05-17 02:14:08
【问题描述】:

我收到一些错误提示它找不到符号

import javax.swing.JOptionPane;

public class ShippingSales
{
    public static void main (String [] args)

{
    int weight,  miles;
    String temp;
    double shippingcharge, rate;

    shippingcharge = miles * rate;
    miles = 500;

    temp = JOptionPane.showInputDialog("Enter the weight of the package");
    weight = Interger.parseInt(temp);

    if (weight <= 2)
    {
        JOptionPane.showMessageDialog(null, "Your total amount is " + shipppingcharge);
        rate = 1.10;
    }

    if (weight > 2 && weight<= 6 )
    {
        JOptionPane.showMessageDialog(null, "Your total amount is " + shipppingcharge);
        rate = 2.20;
    }

    if (weight > 6 && weight<= 10)
    {
        JOptionPane.showMessageDialog(null, "Your total amount is " + shipppingcharge);
        rate = 3.70;
    }

    if (weight > 10)
    {
        JOptionPane.showMessageDialog(null, "Your total amount is " + shipppingcharge);
        rate = 3.80;
    }

}


}

【问题讨论】:

  • 哪些符号?如果编译器说找不到shipppingcharge。你只需要检查你的拼写是否正确——事实并非如此。 Interger 也一样。

标签: java error-handling


【解决方案1】:
 Interger.parseInt(temp);

你一眼就能看出这条线有什么问题吗?

提示:拼写。

此外,您在变量引用中多次拼错“运费”。

【讨论】:

    【解决方案2】:

    好吧,您在所有 showMessageDialogs 中都使用了三个“p”,但变量名为 shippingcharge

    你拼错了Integer,你用的是Interger

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多