Homework 3 - Decision Logic Part 1
Part 1 Create a webpage that contains a script that inputs a student's homework average and final exam score (both as integers). Calculate the student's final average according to the formula:
final average = .7 * hwAvg + .3 * finalExam

Using an alert or form text boxes, display the student's final average (rounded to an integer) and final letter grade using the following:
90-100 A
80-89 B
70-79 C
60-69 D
0-59 F

If the student's final grade is 'D' or 'F' then alert "Student must retake the course".

Part 2 A large company pays its salespeople on a commission basis. The salespeople receive $200 per week, plus 9% of their gross sales for that week. For example, a salesperson who sells $5000 worth of merchandise in a week receives $200 plus 9% of $5000, or a total of $650. You have been supplied with a list of the items sold by each salesperson. The value of these items are as follows: Item Value
1 239.99
2 129.75
3 99.95
4 350.89

Create a webpage that contains a script that inputs one salesperson's items sold for last week, calculates how much the salesperson sold and how much they earned, and then outputs XHTML text that displays this data. Be sure to round the outputted results to 2 decimal places. Use prompts or form text boxes to input the number sold for each of the items 1-4. Here is a page of sample input and sample output.

Part 3 Create a webpage that contains a script that will determine the gross pay for each of three employees. The company pays "straight time" for the first 40 hours worked by each employee and pays "time and a half" for all hours worked in excess of 40 hours. You are given a list of the employees of the company, the number of hours worked last week and the hourly rate of each employee. Your script should input this information for each employee, determine the employee's gross pay and output XHTML text that displays the employee's gross pay. Be sure to round the outputted results to 2 decimal places. Use prompts or form text boxes to input the data.
Part 4 A palindrome is a number or a text phrase that reads the same backward and forward. For example: 12321, 55555, 11611, 45554. Create a webpage that contains a script that reads in a five-digit integer (not starting with zero) that determines and outputs a message stating whether or not it's a palindrome. If the number is not five digits long, display an alert indicating the problem to the user. Allow the user to enter a new value after dismissing the alert dialog. [Hint: the string method charAt() is useful in solving this problem.]
Extra Credit Create a webpage that contains a script that reads in the size of the side of a square and outputs XHTML text that displays a hollow square of that size constructed of asterisks. Your script should work for squares of all side sizes between 2 and 10. Display an error message if the user enters any number that is not between 2 and 10.

HOME