我需要使用if语句使用这些事实来制定逻辑。
您需要为以下内容声明变量,并在指定的位置初始化它们。
我的问题在于第二个事实。我似乎无法表达其逻辑。
这是我到目前为止所做的。
public static void main(String args[]){
JOptionPane jo = new JOptionPane();
double minCharge = 35.00;
double signCost = 0.00;
String charColor = "gold";
String woodType = "oak";
int charNum = 8;
String signName =jo.showInputDialog("Enter the sign name");
String signCharColor =jo.showInputDialog("Enter the character color");
String typeOfWood =jo.showInputDialog("Enter the type of wood to be made");
signCost = minCharge;
if(signCharColor.equalsIgnoreCase(charColor))
signCost += 15;
if(typeOfWood.equalsIgnoreCase(woodType))
signCost += 20;
if(signName.length() > 5)
signCost = ;
String hold= "\n| The charge for this sign is $"+signCost+"|";
jo.showMessageDialog(null, new JTextArea(hold));
}
}
答案 0 :(得分:0)
让我们看看:
前五个字母或数字包含在最低费用中;每增加一个角色需要收取4美元的费用。
在伪代码中:
if sign-length <= 5:
charge stays the same
else:
charge = charge + (sign-length - 5) * rate-per-character
应该让你去......
答案 1 :(得分:0)
前五个字母或数字包含在最低费用中;
所以检查字符串的长度
每增加一个角色需要收取4美元的费用。
将额外费用相乘
if (signName.length() > 5) {
signCost += 4*(signName.length() - 5);
}