javascript转换器价格未定义

javascript转换器价格未定义,javascript,converter,Javascript,Converter,我在完成此javascript转换咖啡价格时遇到问题 <html> <head> <title>Coffee House</title> </head> <body> <script type="text/javascript"> var drink, ounces, price; prompt ( "Enter the drink type: espresso, latte, cappuccino, ameri

我在完成此javascript转换咖啡价格时遇到问题

<html>
<head>
<title>Coffee House</title>
</head>
<body>
<script type="text/javascript">
var drink, ounces, price;
prompt ( "Enter the drink type: espresso, latte, cappuccino, americano" );
prompt ( "Enter the oz: 8, 12, 16" )
var shots = prompt ( "Enter the number of shots" )
if ( drink == "espresso")
price = 1.40;
if (( drink == "latte") || (drink == "cappuccino" ))
{
if ( ounce == 8 )
price = 1.95;
else if ( ounce == 12 )
price = 2.35;
else if ( ounce == 16 )
price = 2.75;
}
if ( drink == "americano" )
price = 1.20 + ( ( (ounce -8)/8 ) * .30 );
price = price + ( (shots) * .50 );
price = "price" * 1.055;
price = Math.round( price * 100 )/100;
alert( "Your " + ounce + "oz. " + drink + "with " + shots + "shots of espresso costs: $ " +price );
</script>
</body>
</html> 

咖啡馆
var饮料,盎司,价格;
提示(“输入饮料类型:浓缩咖啡、拿铁、卡布奇诺、美式咖啡”);
提示(“输入oz:8、12、16”)
var shots=提示(“输入放炮次数”)
如果(饮料=“浓缩咖啡”)
价格=1.40;
如果((饮料=“拿铁”)| |(饮料=“卡布奇诺”))
{
如果(盎司==8)
价格=1.95;
否则,如果(盎司==12)
价格=2.35;
否则,如果(盎司==16)
价格=2.75;
}
如果(饮料==“americano”)
价格=1.20+((盎司-8)/8)*.30);
价格=价格+((镜头)*.50);
price=“price”*1.055;
价格=数学整数(价格*100)/100;
提醒(“您的“+盎司+”盎司“+饮料+”和“+杯数+”杯浓缩咖啡的价格:$”+价格);

这是删除所有错误后的JavaScript:

var drink, ounces, price;
drink = prompt("Enter the drink type: espresso, latte, cappuccino, americano");
ounces = parseInt(prompt("Enter the oz: 8, 12, 16"));
var shots = parseFloat(prompt("Enter the number of shots"));
if (drink === "espresso") price = 1.40;
if ((drink === "latte") || (drink === "cappuccino")) {
  if (ounces === 8) price = 1.95;
  else if (ounces === 12) price = 2.35;
  else if (ounces === 16) price = 2.75;
}
if (drink === "americano") price = 1.20 + ((ounces - 8) / 8) * 0.30;
price = price + shots * 0.50;
price = price * 1.055;
price = Math.round(price * 100) / 100;
alert("Your " + ounces + "oz. " + drink + "with " + shots + "shots of espresso costs: $ " + price);

谢谢你,伙计,但它仍然说盎司是未定义的。我应该改变什么?谢谢你。除了最后它说的是price=NaN之外,这是什么意思?@user1371539:
NaN
的意思是“不是一个数字”。在某个地方,你试图对一些不是数字的东西进行数学运算。(可能是一个字符串形式的数字)好吧,我欠你的,还有一些信用。sweet我必须检查一下我有一个额外的信用java脚本,关于整数1-10的平方、立方和四次方