我需要打印起始价格,然后是一个选项卡,然后是地毯的成本(我已经为此编写了一个返回方法,但不确定如何调用它),然后是一个选项卡,然后是配件的成本。
返回方法如下:
private double calculateCarpetCost(int length, int width, double price) {
return (length * width) * price;
}
private double calculateFittingCost (int length, int width, double price, double costMultiplier){
return (length * width) * labourCharge;
}
这就是我所做的,但每次我执行它时,而不是一个值。标题就出现了。例如..carpetcostestimator.getdoubleprice...而不是价格.eg 50.如何使用上面的方法来调用方法并获得答案。
System.out.print("CarpetCostEstimator.getdoubleprice" +
"\t\t" +
"getcalculateCarpetCost" +
"\t");
最佳答案
问题缺少信息。
尽管如此,您将这两个方法都打印为字符串。从两个方法调用中删除双引号。
System.out.print(CarpetCostEstimator.getdoubleprice +"\t\t"+getcalculateCarpetCost"+"\t");
关于java - 如何在同一个类中调用Java方法并system.out.print结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59287174/