我是java新手,我遇到了以下代码的问题。我试图将一个双变量转换为一个字符串变量,以便在JOptionPane.showMessagedialog中使用它,但它给我一个错误,如下所示。
import javax.swing.JOptionPane;
public class pricecalculatorchap5
{
public static void main(String [] args)
{
String priceinput;
double wholesaleprice;
double markupprice;
double retailprice;
String retailprice2;
String pricecalculated;
priceinput = JOptionPane.showInputDialog("Please enter the whole sale price of the item.");
wholesaleprice = Double.parseDouble(priceinput);
priceinput = JOptionPane.showInputDialog("Please enter the markeup price of the item.");
markupprice = Double.parseDouble(priceinput);
retailprice = ( (markupprice / 100) * wholesaleprice) + wholesaleprice;
retailprice2 = Double.toString (retailprice);
pricecalculated = JOptionPane.showMessageDialog("The price of the item is calculated as " + retailprice2 );
}
}
错误
pricecalculatorchap5.java:28:错误:找不到合适的方法 showMessageDialog(字符串) pricecalculated = JOptionPane.showMessageDialog("项目的价格计算为" + retailprice2);
^ 方法JOptionPane.showMessageDialog(Component,Object)不适用 (实际和正式的参数列表长度不同) 方法JOptionPane.showMessageDialog(Component,Object,String,int)不适用 (实际和正式的参数列表长度不同) 方法JOptionPane.showMessageDialog(Component,Object,String,int,Icon)不是 适用 (实际和形式的参数列表长度不同)1错误