CSD 340: The Week beginning Jan. 24
- Reading:
Chapter 2 in Beginning JavaScript
- Homework:
- Write a page that has the user enter three CYM values given as
percentages (values between 0 and 100) and displays the corresponding
RGB values (values between 0 and 255) and finally the hexadecimal code.
Then display the color using a <div>
You can use prompt for the user to enter data. First put the two
schemes on the same scale by multiplying the CYM values by 255 and dividing
by 100.
C2 = 255 * C / 100
Then note that the amount of red is opposite to the amount of cyan
R = 255 - C2
Final convert the RGB values to hexadecimal and concatenate the
three values and use the result to create a division of the desired color.
(You might want to use the predefined function ConvertDecimalToHex.
Due Jan. 31
Monday:
Errors and Debugging and Swapping Variable Values
(supporting files Error.htm, Error2.htm,
Swap.htm, Sun.gif, and
Moon.gif. As the names suggest Error.htm and Error2.htm contain
intentional errors.)
Wednesday:
Ifs (supporting file ReadableType.htm).
Time permitting go over ShadeOfRed.htm.
Friday:
- Look at the code for the Date object demonstration. (See p. 143 of
Beginning JavaScript.)
- Write a script that has the user enter a number between 0 and 6 and then displays
the corresponding image from the following set
(BannerDay0.gif,
BannerDay1.gif,
BannerDay2.gif,
BannerDay3.gif,
BannerDay4.gif,
BannerDay5.gif,
BannerDay6.gif).
- Comment out the code that has the user enter the number and adapt the above script so that it
gets the number from dateNow instead of the user.
- Now write a scrpt that has the user enter two numbers: the first between 0 and 6 (corresponding
to the day of the week) and the second between 0 and 23 (corresponding to the hour of the day). Then
use this information to determine your location at the given day and time. Start off with a location
variable having a value "Your guess is as good as mine." But then start looking for conditions
under which your location is known. For example if the day is Monday, Wednesday or Friday
and the hour is nine o'clock, then change the value of the location variable to "I should be
in Olney 127."
- Comment out the code that has the user enter the numbers and adapt the above script so that it
gets the numbers from dateNow instead of the user.