したがって、>=largeOrder を使用した if ステートメントを除いてすべてが機能しており、割引は適用されません。また、請負業者である従業員の場合もそうではありません。従業員が請負業者である場合、従業員は請負業者の割引を受けることができます。しかし正規業者のif文は完璧で問題なく動いています。すべての出力はそのために正しいです。だから、ネストされたifステートメントで何かを推測しています...
//assumptions
var employeeDiscount = .1;
var largeOrder = 800;
var largeOrderDiscount = .05;
var smallOrderDiscount = 0;
var contractorDiscount = .2;
var salesTax = .08;
var seniorTax = 0;
var seniorAge = 90;
var tax, typeOfCustomer, orderAmount, employeeContractor;
var discount, discountAmount, subtotal, finalPrice, taxTotal;
//input
age = prompt("How old is the customer", "");
age = parseInt(age);
orderAmount = prompt("How much is the order", "");
orderAmount = parseInt(orderAmount);
typeOfCustomer = prompt("What type of customer is it, regular, employee, or contractor", "");
//calculations
if (age >= seniorAge) {
tax = seniorTax;
} else {
tax = salesTax;
}
if (typeOfCustomer == "regular") {
if (orderAmount >= largeOrder) {
discount = largeOrderDiscount;
} else {
discount = smallOrderDiscount;
}
}
if (typeOfCustomer == "employee") {
employeeContractor = prompt("is the employee a contractor?", "");
if (employeeContractor == "yes") {
discount = contractorDiscount;
} else {
discount = employeeDiscount;
}
}
if (typeOfCustomer == "contractor") {
discount = contractorDiscount;
} else {
discount = smallOrderDiscount;
}
taxTotal = orderAmount * tax;
discountAmount = orderAmount * discount;
subtotal = orderAmount - discountAmount;
finalPrice = subtotal + taxTotal;
//output
document.write("Order amount: $" + orderAmount);
document.write("<br>Discount amount: $" + discountAmount);
document.write("<br>Subtotal: $" + subtotal);
document.write("<br>Taxes: $" + taxTotal);
document.write("<br>Final Price is: $" + finalPrice);
// -->
</script>