java - 修改 calculateFittingCost() 方法,使其将可变劳动力成本乘以适当的成本乘数
问题描述
所以我正在创建一个程序来计算地毯的供应和安装成本。
我正在努力修改以下代码,以便将可变劳动力成本乘以适当的成本乘数。
private double calculateFittingCost (int length, int width, double price)
return (length * width) * labourCharge;
}
这是关于成本乘数的部分
public double costMultiplier() {
double multiplier = 1.0;
if (postCode != null) {
if (postCode.toUpperCase().startsWith("WC1A") || postCode.toUpperCase().startsWith("EC1A")) {
multiplier = 1.2;
}
}
return multiplier;
}
解决方案
假设你的公式是:
拟合成本 = l * w * unitPrice * 乘数
private double fittingCost(double unitAreaPrice, double length,double width, String postalCode ){
return unitAreaPrice * length * width * computeMultiplier(postalCode);
}
private double computeMultiplier(final String postalCode){
final double LOW = 1.0;
final double HIGH = 1.2;
if (postalCode.toUpperCase().startsWith("WC1A") || postalCode.toUpperCase().startsWith("EC1A")) {
return HIGH;
}
return LOW;
}
推荐阅读
- sql-server - 无法连接到 sqlserver docker 映像
- sling - jackrabbit accessmanager:如何创建具有限制 rep:glob="/foo" 的 ACL
- encryption - 如何恢复和解密被 Grandcrab 勒索软件病毒加密的文件
- javascript - 当我单击按钮组中的按钮时更改许多按钮的值(文本)
- salesforce - Salesforce 个案评论更新创建者姓名
- selenium - Selenium Webdriver ConnectionAbortedError 在命令之间休眠 5 秒的情况下
- javascript - 在 API 调用 NgRx Angular 之前检查商店
- tensorflow - 目前是否可以将 ssdlite mobilenet v2 转换为 tflite 模型?
- codenameone - 代号一:检测“caps lock”键
- c# - Xamarin.Android 应用程序如何访问复制到输出目录设置为 CopyAlways 的文件?