CMSI 185 Homework #4
Due Tuesday, November 17
  • Read: The Wikipedia page on Standard Deviation.

  • Make:

    1. A JavaScript program that determines the number of days in a given month. The input should be a single string, e.g., "2 1900" (for February, 1900). The script should disallow all bad data- e.g., improper months, years prior to 1600, etc.- by repeatedly prompting for input until good data arrives. The output should be a single number. Note: Except for processing the input string (with String.split()), you do not need, nor should you use, arrays or JavaScript Date objects for this problem.

    2. A JavaScript program that determines the number of days between two given dates. The script should prompt for two strings like 12 1 2009 and 3 1 2010. If the same date is given twice, the answer is zero; for consecutive days, the answer is one; etc. The script should disallow bad data- e.g., improper months, days that don't occur in the given month, years prior to 1600, etc.- by repeatedly prompting for input until good data arrives. Again, the output should be a single number. Note: Except for processing the input strings (with String.split()), you do not need, nor should you use, arrays or JavaScript Date objects for this problem.

    3. A JavaScript program that determines the average of an arbitrary list of numbers. Your script should prompt once, for a single string, which will contain all of the data (numbers, separated by commas, e.g., the input might be a string like 23,-1.23,10,10,3.1416,1000 .

    4. A JavaScript program that determines the standard deviation of an arbitrary list of numbers. Again, your script should prompt once, for a single string, which will contain all of the data (numbers, separated by commas.

  • To submit your programs, "publish" them on your website. In particular, put links on your home page to Days in Month, Days Between Two Dates, Average, and Standard Deviation.


  • Revised at 1:30 on 10 November 2009