﻿ Second JavaScript Assignment

# JavaScript Assignment #2

1. (15 points) Use the psuedo code below to write a JavaScript program to demonstrate the same logic.
```start
var1 = 10
var2 = 20
wksum = 0
rslt = 0
do while var2 < 30
wksum = var1 + var2
if wksum > 30
var1 = var1 - 2
var2 = var2 + 1
else
var1 = var1 - 1
var2 = var2 + 3
end if
end while loop
rslt = var1 + var2
display rslt
end
```
2. (15 points) Write a JavaScript program that asks the user to input their age. Based on the user's input, the output (to the browser window) will display one of the following results:
If the person is over 65, the output should be "You are eligible for the discounted senior rate."
If the person is between the age of 12 and 64, the output should be "You are eligible for the regular adult rate."
If the person is 11 or under, the output should be "You are eligible for the discounted child's rate."
Hint: Order is an important consideration when solving this problem!
3. (20 points) Take in the total amount of a donation you pledged and the number of payments that you plan to make and determine the amount of each payment. Say if you pledge 100 and say you are making 4 payments that means 25 dollars per payment. Display the amount of the payment.
4. (25 points) You have a product that is on sale. Each day of the sale, the price drops 10% from its previous price. The sale lasts for 4 days. You should write a program that processes this problem using a loop. Take in the original cost of the item. For each pass through the loop should generate the sales price for each day the item is on sale along with the day number. For example, if the item costs \$10, your output will say "Day 1: Sales Price x, Day 2: Sales Price y", etc. (replacing x and y with the correct sales price total).
5. (25 points) You need to calculate the total water bill for a household. If the household has utilized at least 100 gallons they will pay \$1 per gallon for the first 25 gallons and \$0.50 for the remaining gallons. If they have not utilized at least 100 gallons, they will be charged \$1 per gallon for the first 50 gallons and \$0.50 for the remaining gallons.