Lesson Seven, Part 10, Creating a Price list
You have been asked to help out store with their discounting of their merchandise. They are trying to encourage customers to purchase more than one of each item. To accomplish this they have decided to discount each additional item 2%. So if they item originally cost $100 and the customer wanted to see how much each additional item would cost them the user wants to present them with a list of the prices.
Grill = $100
A list of 10 grills would be as follows:
|
1. $100.00 |
|
2. $ 98.00 |
|
3. $ 96.04 |
|
4. $ 94.12 |
|
5. $ 92.24 |
|
6. $ 90.39 |
|
7. $ 88.58 |
|
8. $ 86.81 |
|
9. $ 85.08 |
|
10 $ 83.37 |
You need to create a program that will produce 10 prices based upon what the original prices of the item.
Once you get this working, I want you to create a function that will do this math when the price of the item is sent to it and the list of items is returned.
Now code it: answer
<script language=vbscript>
Option Explicit
dim price, itemname, loopnumber, pricelist
price = inputbox("What is the price of the time")
itemname = inputbox("What is the name of the time")
Do While loopnumber <10
loopnumber = loopnumber + 1
If loopnumber = 1 then
pricelist = "A list of 10 " & itemname &"s would be as follows: <br>1. $" &
price
Else
price = price * .98
pricelist = pricelist & "<br>" & Loopnumber & ". " & formatcurrency(price)
end if
Loop
Document.write pricelist
</script>