Java第二个静态方法未执行

Java第二个静态方法未执行,java,methods,Java,Methods,我不明白为什么第二个方法不执行。它编译并接受输入,但之后什么也不会发生。有人能给我指出正确的方向吗 import javax.swing.JOptionPane; public class Test1 { public static void main(String[] arg) { String hoursOfWorkString, costOfMaterialsString, nameOfProductString; nameOfProductS

我不明白为什么第二个方法不执行。它编译并接受输入,但之后什么也不会发生。有人能给我指出正确的方向吗

import javax.swing.JOptionPane;

public class Test1 {
    public static void main(String[] arg) { 
        String hoursOfWorkString, costOfMaterialsString, nameOfProductString;

        nameOfProductString = JOptionPane.showInputDialog(null, "Enter the name of the product. ", JOptionPane.QUESTION_MESSAGE);   
        hoursOfWorkString = JOptionPane.showInputDialog(null, "Enter the number of hours worked. ", JOptionPane.QUESTION_MESSAGE); 

        double hoursOfWork = Double.parseDouble(hoursOfWorkString);

        costOfMaterialsString = JOptionPane.showInputDialog(null, "Enter the cost of the product. ", JOptionPane.QUESTION_MESSAGE);           
        double costOfMaterials = Double.parseDouble(costOfMaterialsString);
    }



    public static void CalulatePrice(double costOfMaterials, double hoursOfWork, String nameOfProductString) {
        double salePercentage = 0.75, shipping = 6, markup = 14, retailPrice;

        retailPrice = salePercentage * (costOfMaterials + (markup * hoursOfWork)) + shipping; 

        JOptionPane.showMessageDialog(null, String.format("The retaill price of the %. product is $ %.02f.", nameOfProductString, retailPrice));
    }
}
更新:我使用了这个示例并修复了一些其他错误,它运行起来了。看完评论后,我认为这是行不通的。我只知道我的代码有问题


谢谢大家的支持。

这是因为您已经定义了函数,但还没有调用它。在
main
方法的末尾插入一个调用,如

double costOfMaterials = Double.parseDouble(costOfMaterialsString);
// Here...
CalulatePrice(costOfMaterials, hoursOfWork, nameOfProductString);

还有,我想你的意思是计算。而且,请遵循Java命名约定,它应该类似于
calculatePrice

,可能是因为您没有调用它?我很想知道您为什么认为它会执行。