新用户在这里。谁能帮我解决这个问题?在此处参考问题http://i.imgur.com/e8UbQfB.jpg
这是我到目前为止所做的,当然充满了错误,如果我使用 switch case 是否正确?或者我可以使用 if...else 语句?
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
var price;
var weight = parseFloat(prompt("Enter amount of laundry: ", ""));
var rate;
switch (weight)
{
case 1:
rate = weight <= 10;
price = 2.00;
break;
case 2:
rate = weight >= 10 && weight <= 20;
price = 1.50;
break;
case 3:
rate = weight >= 20;
price = 1.00;
break;
}
var total = price * weight;
alert
(
"\nWeight : " + weight +
"\nRate : " + price +
"\nTotal : RM " + total
);
</script>
</head>
</html>`