MAHLONAA 发表于 2008-3-18 09:17

我的java哪个部分错了?

var item
var tax
var totalcost

//input

item = inputString ("Enter the letter corresponding to the item you are interested in")

tax = inputNum ("Enter provincial sales tax rate (in $)", 0.08,2)

//processing
if (item=="a")
{
outputLine ("Item (a):")
outputLine ("T-Shirt: Grey")
totalcost= (1+tax)*10
output ("Cost with tax: $"+totalcost)
}

if (item=="b")
{
outputLine ("Item (b):")

outputLine ("Sweater: White")
totalcost= (1+tax)*12
outputLine ("Cost with tax: $"+totalcost)
}

if (item=="c")
{

outputLine ("Item (c):")

outputLine ("Jean: Blue")
totalcost= (1+tax)*20

outputLine ("Cost with tax: $"+totalcost)
}
if (item=="d")

{
outputLine ("Item (d):")

outputLine ("Boot: Black")
totalcost= (1+tax)*23

outputLine ("Cost with tax: $"+totalcost)
}
else
{
outputLine ("there is no such item")
}
</script>

可以帮我改改如何可以让totalcost最多只可以有2位小数点?
还有最后的else part为什麽也有错,每次得出的答案就算属於a的else那个部分还是会出现

lmhllr 发表于 2008-3-18 13:50

还是先看看提问的技巧吧.....看不懂

[[it] 本帖最后由 lmhllr 于 2008-3-18 15:53 编辑 [/it]]

wyg4859 发表于 2008-3-18 14:40

若非这就是传说中的jscript?看不懂啊!

页: [1]

编程论坛