JAVA HELP- programming (choices/ calculations) HELP!?

Question by KM: JAVA HELP- programming (choices/ calculations) HELP!?
I am supposed to create a webpage to provide users with information about various items in an online store. The website should ask the user to enter the item they are interested in and print information about their choice (including price after tax) directly on the webpage.

For example, a screenshot of the website after the input includes:
-provincial tax rate (in $ ): 0.08
-letter that you are corresponding to item you are interested in: b

Bill’s Online Store-
Information Utlity

____________________
a- T Shirt ($ 10.00)
b- Sweater ($ 12.00)
____________________

Item (b):
Sweater: Cashmere!
Cost with tax: $ 13.68

The finished webpage should include:
-4 items that the store sells
-It should calculate the final sales price of an item
-It should ask for the PST rate price
-It should output the name of the item and some additonal information (colour, material, etc)
-Output can only display 2 decimal places
– comments should be added appropriately

So far I have:



Sample Online Store

// Simple function to return the cost of the desired item
function costOfItem(item)
{
var cost

if (item == “a”){
cost = 15
} else if (item == “b”){
cost = 30
} else {
cost = 0
}

return cost
}


Sample Online Store – Information Utility

——————————-

a – T-Shirt ($ 15.00)

b – Sweater ($ 30.00)

——————————-

const GST = 0.07
const PST = 0.06
var total
var item

item = prompt(“Enter the letter corresponding to the item you are interested in”)

total = costOfItem(item)

document.write(“Item (” + item + “): “)

// This line is not correct as it does not add the tax.
document.write(“
Cost with tax: $ ” + total)


HELP?!

Best answer:

Answer by Steven C


Sample Online Store


Sample Online Store – Information Utility

——————————-

a – T-Shirt ($ 15.00)

b – Sweater ($ 30.00)

——————————-



You weren’t doing any calculations to calculate the tax.

What do you think? Answer below!

Get the book now