Assignments for CSC 160
Spring, 2006
Assignment 1:
Create a personalized web page with at least two paragraphs, a list, two links, and one picture. If you do not use a picture from
http://www.cs.eku.edu/faculty/styer/160/pics.html remember to include the picture when you submit the html file to Blackboard.
Next time, require picture submission regardless?
Assignment 2:
Write a paper (minimum length: one single-spaced typed page)
comparing JavaScript and Java. Remember to cite any
books or web pages you use for your paper.
Assignment 3:
Create a page that will display the following text on
the screen:
My name is John Doe
I am currently taking CSC 160
The general structure of your page (and the italic effects) should
be similar to the example on page 57-58.
In the script section (in this assignment and for the rest of the
semester) you should have the comments
<SCRIPT language="JavaScript">
// John Doe
// CSC 160
// Assignment 3
...
Note: Rembember that as comments, these will not show
up on the web page. These are to help us as programmers.
Assignment 4:
Create a page that asks the user for an adjective
and displays the adjective, the comparative and
superlative forms of that adjective. Create two functions
comparative and superlative to create these
forms (they will be similar to the
example pluralize discussed in class). For the purposes of
this assignment, you may assume that adding "er" or "est"
will form the proper comparative and superlative forms
of the adjective.
A few examples:
smart smarter smartest |
yellow yellower yellowest |
pretty prettyer prettyest |
Note: I want the page to be set up so that when the user
loads the page, they would type the adjective ("smart") once, and
then the program will display "smarter" and "smartest" on
the page and stop. The user will reload the page if they want
to try again with a different adjective ("smarter" or "smartest").
You can see how the page should look to the user
Here. Note the underlying JavaScript has been
intentionally obscured so you cannot simply copy this
code.
Next time, require the main program to do the document.write
Assignment 5:
The Styer Computer Company is paying bonuses to each
employee of the company. Employees who have been with
the company for 10 or more years will be a bonus of 9% of
their salary. Employees who have been with the company
at least three years (but less than 10) get a bonus of 5% of
their salary. Employees who have been with the company less than
3 years get a bonus of 1% of their salary. Ask the user
for the employee's salary and how long may years they have
been an employee, and display using window.alert()
the amount of their bonus.
You can see how the page should look to the user
Here. Note the underlying JavaScript has been
intentionally obscured so you cannot simply copy this
code.
Assignment 6:
Create a page that will help professor I. M. Lazy calculate grades
for his class. Begin by asking Prof. Lazy how many students are in
the class. Then for each student, ask for the student's name and
the three test scores.
Then calculate the average of the three tests, and
display (using document.write()) the student's name and
average, one line per student.
You can see how the page should look to the user
Here. Note the underlying JavaScript has been
intentionally obscured so you cannot simply copy this
code.
Assignment 7:
For this assignment we will create a simple slot machine.
Assume we have a slot machine with three reels, each of which
contains nine distinct symbols (for our purposes, we will simply use
the digits 1-9). To play, the person will insert one token and
pull the handle. The machine will randomly select one of the
nine available symbols for each reel. If all three symbols are
the same (Note: remember that '==' only compares two
values, you will need a logical operator here), the machine
will discharge 32 tokens. If any two of the three reels show the
same symbol, the machine will discharge 2 tokens. If all three
symbols are different, the player loses. If the player runs out
of tokens, they must leave and let somebody else play.
Your page should have two buttons. The first button is a "New Player"
button, and initializes the player's balance to 10 tokens.
The second button will equivalent to putting a token in the
machine and pulling the handle. Use window.alert() to
tell the user how much (if anything) they won.
You should display the current balance (in tokens) in the status line.
You can see how the page should look to the user
Here. Note the underlying JavaScript has been
intentionally obscured so you cannot simply copy this
code.
Assignment 8:
Create a page that implements a simple three minute egg timer.
The page should have a single button "Start" that starts the timer.
The remaining time should be displayed in the status bar.
When the timer is finished, you should display an alert()
box that says "Done!"
You can see how the page should look to the user
Here. Note the underlying JavaScript has been
intentionally obscured so you cannot simply copy this
code.
Next time, have it display only in seconds??
Assignment 9:
Create a page that will get 11 scores from the user and display
the mean and median scores. The mean score is simply the average.
The median score is the middle score (five of the scores will be
above it and the other five will be below it).
Note: Due to the way sort() works, you should
assume all grades are in the range from 10 to
99.
Next time, require loop or user-entered # of scores?
Assignment 10:
Einstein's relativity theory tells us that objects become shorter (as measured by a
stationary observer) as they move faster. This can be calculated by the equation:
Where
- L0 = The length of the object at rest (assume the object is
10 meters long for this exercise)
- v = The speed of the object in meters/second
- c = The speed of light (299,792,458 meters/second)
Create a HTML/JavaScript page to do the following:
When the user presses a button, ask the user (using window.prompt()) for the speed and calculate the new
length of the object at the given speed. Display the length using 4 digits
after the decimal point.
If the user supplies a speed greater than
c, display an error message instead.
Sample results:
| Speed |
Length |
| 10,000,000 m/s |
9.9944 m
|
| 100,000,000 m/s |
9.4273 m
|
| 200,000,000 m/s |
7.4494 m
|
Some sample speeds to try:
| Land Speed Record | 341.1 m/s |
| Space Shuttle | 7800 m/s (depends on exact orbit) |
| Helios 2 spacecraft | 70630 m/s |
Next time, specify output using window.alert()
Assignment 11:
Create a page to help handle a pizza buisness.
The page should display a form for ordering a pizza.
The user should have a choice between Large, Medium,
and Small pizzas, and have a choice of at least four
toppings.
Have a button the user can press to order the pizza.
Then you should display the cost of the pizza
in a read-only text box.
You may choose for yourself the cost of each size of pizza and the cost
of each topping.
To create a read-only text box, use:
<INPUT type="text" name="abc" readonly>
Assignment 12:
For this (last!) assignment we will revisit the slot machine program
and make it more interesting by using images and form elemements.
Your page should have three image areas
You can see how the page should look to the user
Here. Note the underlying JavaScript has been
intentionally obscured so you cannot simply copy this
code.
I will ask that you use links to the pictures below.
If you want to create and use your own pictures, please
submit them along with your page in Blackboard.
Pictures and corresponding URLs:
| http://www.cs.eku.edu/faculty/styer/160/balloon.gif
|
| http://www.cs.eku.edu/faculty/styer/160/bar.gif
|
| http://www.cs.eku.edu/faculty/styer/160/7.gif
|
| http://www.cs.eku.edu/faculty/styer/160/cherry.gif
|
| http://www.cs.eku.edu/faculty/styer/160/dbar.gif
|
| http://www.cs.eku.edu/faculty/styer/160/lemon.gif
|
| http://www.cs.eku.edu/faculty/styer/160/bell.gif
|
| http://www.cs.eku.edu/faculty/styer/160/tbar.gif
|
| http://www.cs.eku.edu/faculty/styer/160/banana.gif
|
160 Class page
My Home Page