问题描述
/**
* @param newProfitMarginParam is used to set the gained profit margin.
*/
public void setCalculateProfitMargin(double newProfitMargin){
this.profitMargin = (this.sellingPrice - this.dealerCost) / this.sellingPrice;
}
/**
* A method to calculate the profit.
*/
public void calculateProfit(){
double dollar = this.sellingPrice - this.dealerCost;
}
public void main(String[] printDetails){
System.out.println("Jalopies Are Us Vehicle Summary:");
System.out.println("Vehicle: " + this.year + " " + this.make + " " + this.model);
System.out.println("Stock code: " + this.stockCode);
System.out.println("Dealer Cost: $" + this.dealerCost);
System.out.println("Selling Price: $" + this.sellingPrice);
System.out.println("Profit Margin: " + this.profitMargin + "%");
System.out.println("Dollare Profit: $");
calculateProfit();
}
例如,在这里我要在主方法中添加上述方法。
我怎样才能做到这一点?
我在main方法中添加了最后一条语句,但没有收到任何Syntex错误,但是我不确定它是否正确。
另外,我该如何添加第一种方法呢?
1楼
这些概念可以帮助您更好地理解代码的问题: