2017-08-06 7 views
0

以下のコードに問題があるjavaとimには新規です。私はJOptionPane.showMessagedialogでそれを使用するために、ダブル変数を文字列変数に変換しようとしていますが、それは私に以下に列挙されるエラーを与えます。 Componentといつも一緒JOptionPaneに二重変数を挿入する

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); 


    } 
}  

ERROR

pricecalculatorchap5.java:28: error: no suitable method found for showMessageDialog(String) pricecalculated = JOptionPane.showMessageDialog("The price of the item is calculated as " + retailprice2);
^ method JOptionPane.showMessageDialog(Component,Object) is not applicable (actual and formal argument lists differ in length) method JOptionPane.showMessageDialog(Component,Object,String,int) is not applicable (actual and formal argument lists differ in length) method JOptionPane.showMessageDialog(Component,Object,String,int,Icon) is not applicable (actual and formal argument lists differ in length) 1 error

答えて

0

showMessageDialog。サーバーメソッドのオーバーライドがありますが、どれもあなたのようなStringパラメータしか持っていません。 Refer Document

関連する問題