[an error occurred while processing this directive] File: index.shtml Creator: George Ferguson Created: Mon Sep 24 16:19:37 2012 Time-stamp: [an error occurred while processing this directive] File: templates/doc-start.shtml Creator: George Ferguson Created: Tue Dec 6 12:31:29 2011 Time-stamp: [an error occurred while processing this directive] File: site-settings.shtml Creator: George Ferguson Created: Tue Dec 6 13:49:49 2011 Time-stamp: Site (or subsite)-wide settings. [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] File: head.shtml Creator: George Ferguson Created: Tue Dec 6 12:34:15 2011 Time-stamp: SSI variables for this template: head_title if given, else ``sitename | title'' [an error occurred while processing this directive] File: head-title.shtml Creator: George Ferguson Created: Tue Dec 6 14:29:52 2011 Time-stamp: SSI variables for this template: head_title: complete content of title element if given site_title trailing part of title (if given) section_title middle part of title (if given) page_title leading part of title (if given) title title shown on page, also used as leading part of title (if given) [an error occurred while processing this directive] (none) [an error occurred while processing this directive] File: head-meta.shtml Creator: George Ferguson Created: Tue Dec 6 14:29:18 2011 Time-stamp: SSI variables for this template: meta_description meta_keywords meta_generator [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] File: head-stylesheets.shtml Creator: George Ferguson Created: Tue Dec 6 14:22:58 2011 Time-stamp: SSI variables for this template: site_stylesheet, page_stylesheet stylesheet0, stylesheet1, ...: URL for stylesheets [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] File: head-scripts.shtml Creator: George Ferguson Created: Tue Dec 6 14:23:19 2011 Time-stamp: SSI variables for this template: site_script, page_script script0, script1, ...: URLs of javascript scripts [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] File: body-start.shtml Creator: George Ferguson Created: Tue Dec 6 13:20:46 2011 Time-stamp: SSI variables for this template: body_class page_class page_id [an error occurred while processing this directive] [an error occurred while processing this directive] File: body-header.shtml Creator: George Ferguson Created: Tue Dec 6 13:46:12 2011 Time-stamp: Content above banner, if any. [an error occurred while processing this directive] File: body-banner.shtml Creator: George Ferguson Created: Tue Dec 6 13:27:12 2011 Time-stamp: Duplicate URCS Drupal banner. hajim urcs
Computer Science @ Rochester
Computer Science Department : Hajim School of Engineering & Applied Sciences Skip to main content [an error occurred while processing this directive] File: body-title.shtml Creator: George Ferguson Created: Tue Dec 6 14:34:49 2011 Time-stamp: SSI variables for this template: section_name First line of title on page (if any) title Title shown on page

[an error occurred while processing this directive] DMS102/CSC170D: Introduction to Web Development
Spring 2013
[an error occurred while processing this directive]
Assignment 4: Expressions and Conditions

  1. [3 pts] Create a page that (a) asks the user for their favorite flavor of ice cream; (b) uses the answer in a followup question; and (c) and displays the answer to that second question.
  2. [3 pts] Create a page that asks the user for two numbers (that is, asks twice for one number each time) and then displays the numbers and their sum, difference, product, and quotient as a table in the page.
  3. [3 pts] Create a page that asks the user for a number and reports whether or not the number is even. Hint: Think what it means to be even and check out the remainder operator (%).
  4. [3 pts] Fix your script from question 2 so that it displays an appropriate message for the quotient if the user enters the number 0.
  5. [3 pts] Create a page that asks the user for an hour (a number) between 0 and 23 and reports whether the hour corresponds to morning (6-11), afternoon (12-18), or night (18-23 and 0-5).
  6. [3 pts] Create a page that asks the user for their name and their favorite genre (kind) of music, and then does the following:
    • If their favorite style of music is jazz, ask what instrument they prefer. If the answer is saxophone, ask if they prefer soprano, alto, or tenor sax.
    • If their favorite style of music is classical, ask which composer they prefer. If the answer is Mozart, ask which piece is their favorite.
    • Otherwise, ask who is their favorite artist.
    Have your script produce a nice summary of the answers as the content of the page.

Things to think about

  • Understand the difference between strings and numbers (even though Javascript converts many things to strings when necessary).
  • Understand that even though Javascript is a weakly (or loosely) typed language, nonetheless values are typed.
  • Check out the typeof operator which can be helpful in debugging type problems.
  • Conditional statements are the most basic building block of programs that do more than one thing.
  • Understand the role of curly braces ({ and }) in delimiting blocks, especially in if statements.
  • Understand how to use whitespace (indentation) in your programs to improve readability, especially of blocks, but realize that whitespace is almost always not actually meaningful in Javascript (unlike, say, Python).

[an error occurred while processing this directive] File: doc-finish.shtml Creator: George Ferguson Created: Tue Dec 6 13:46:48 2011 Time-stamp: [an error occurred while processing this directive] File: body-footer.shtml Creator: George Ferguson Created: Tue Dec 6 14:43:56 2011 Time-stamp: Content at bottom of page, if any.

Last update: Thursday, 07-Feb-2013 09:41:35 EST

[an error occurred while processing this directive] File: body-finish.shtml Creator: George Ferguson Created: Tue Dec 6 13:47:36 2011 Time-stamp: [an error occurred while processing this directive]