[an error occurred while processing this directive] File: index.shtml Creator: George Ferguson Created: Mon Oct 15 13:24:55 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.
Login
[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
Page Not Found : Department of Computer Science : University of Rochester Skip to main content
Rochester shield
  • Apply
  • Visit
  • Give

Search Rochester.edu

Hajim School of Engineering & Applied SciencesDepartment of Computer Science

Site Navigation

  • About Us
    • Overview
    • What is Computer Science?
    • Employment
    • History
      • 50th Anniversary
      • PhDs Conferred
      • In Memoriam
    • Engagement and Enrichment
    • Giving
    • Contact Us
  • People
    • Full Directory
    • Faculty
    • Graduate Students
    • Staff
  • Undergraduate
    • Overview
    • BS in Computer Science
    • BA in Computer Science
    • Minor and Clusters
    • Courses
    • Advising
    • Getting Experience
    • CS Lab Information
    • Applying
  • Graduate
    • Overview
    • Master's Program
    • PhD Program
    • Courses
    • Applying
  • Research
    • Overview
    • Computer Systems
    • Theory
    • Artificial Intelligence
    • Human-Computer Interaction
  • News & Events
    • Recent News
    • Seminars & Talks
    • Newsletter
    • Distinguished Gifts
    • Commencement

Page does not exist.

  • Overview
  • What is Computer Science?
  • Employment
  • History
    • 50th Anniversary
    • PhDs Conferred
    • In Memoriam
  • Engagement and Enrichment
  • Giving
  • Contact Us
  • Home
  • About Us
  • Contact Us

Missing page.

Sorry. The page you requested does not exist on the Department of Computer Science website

Return to the Computer Science Home Page

Report a Digital Accessibility Barrier

Department of Computer Science

Location
University of Rochester
2513 Wegmans Hall
P.O. Box 270226
Rochester, NY 14627
Phone
(585) 275-5671

Resources for

  • Prospective students
  • Current students
  • Parents & families
  • Faculty & staff
  • Alumni

Schools & divisions

  • School of Arts & Sciences
  • Hajim School of Engineering
  • Eastman School of Music
  • School of Medicine & Dentistry
  • School of Nursing
  • Simon Business School
  • Warner School of Education
  • Laboratory for Laser Energetics

Libraries & collections

  • University Libraries
  • Memorial Art Gallery

Helpful links

  • Intranet
  • Web Communications
  • Contact
  • Directory
  • Human resources
  • UR Mobile (app)
  • Parking & shuttles
  • Information technology
  • Blackboard
  • myURHR
  • MyPath

Ever better

  • Global engagement
  • Accessibility
  • Vision & Values
  • Office of University Engagement and Enrichment
  • Nondiscrimination & Title IX

More URochester

  • News
  • Events
  • Athletics
  • Arts
Two University of Rochester students working on an experiment in a lab.Exterior profile of the University of Rochester’s Eastman School of Music. University of Rochester student plays the violin during a concert.
  • Facebook
  • YouTube
  • X / Twitter
  • TikTok
  • Instagram
  • LinkedIn
  • Threads
  • Follow URochester
Three University of Rochester sophomores posed together while wearing University of Rochester hats. The University of Rochester Rush Rhees Library bell tower at sunrise. Close up of a therapy dog’s nose on the University of Rochester river campus.
University of Rochester logo
  • Contact us
    (585) 275-2121
  • See maps and directions
    Rochester, NY

Search Rochester.edu

  • Privacy
  • Copyright
  • Emergency Information

© University of Rochester 1996–2026

[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 6: Functions

  1. [2 pts] Write a function that takes three arguments and returns their mean (average). Use your function in a page that repeatedly asks the user for three numbers and then prints the numbers and their mean. Choose your own stopping condition (sentinel) and make it clear in your prompt.
  2. [4 pts] Write a page with a script that includes the following:
    • A function named writeTableCell that accepts a single parameter and outputs a table cell containing the parameter's value to the page's document.
    • A function named writeTableRow that accepts 3 parameters and outputs a table row with the 3 values as separate cells.
    The script should use these functions to produce a table for values from 1 to 10 containing the value, the value squared, and the value cubed. That is, for row i, the columns should contain i, i2, and i3.
  3. [4 pts] You're hired by a financial company to spiff up their webpages. First write a function named futureValue that computes how much a given initial sum of money will be worth after a period of time with compound interest (meaning you reinvest the interest). Your function should accept the following three parameters:
    • Initial sum
    • Interest rate
    • Number of years
    It should return the future value of the initial amount if invested for the given number of years at the given interest rate compounded annually. Don't look it up on the web. Think what this means and the way to write the function will be obvious to you. How much will you have after one year? Then what happens to that the second year? And so on.

    Use your function in a page that asks a user for the initial sum of money, and prints a table with the future value at 1%, 3%, and 5% return for 1, 5, and 10 years each. That is, the rows of the table are the different interest rates, the columns are the different terms, and each cell in the table contains the future value of the initial sum for the corresponding rate and term.

  4. [2 pts] Consider the following script:
          // Global variables
          var count = 0;
          var total= 0;
    
          // myfunc: Do something funcky...
          function myfunc() {
              var count = 0;
              count += 1;
              var n = parseInt(window.prompt("Enter a number"));
              total += n;
              document.write("<p>");
    	  document.write("count=" + count + ", total=" + total);
              document.write("</p>");
          }
    
          // Main program starts
          myfunc();
          count = 10;
          myfunc();
          total = 42;
          myfunc();
    
    Copy the code into a script element in a document. Run it (load the page). Then add a paragraph to the document explaining the behavior of the program (that is, why it output what it did).

Things to think about

  • Every function you define should come with a comment that explains its purpose (briefly), its arguments, and its return value. Not only will the TAs be checking for this in your submission, it's also the Right Thing To Do.
  • It is important when defining functions to use meaningful names for both the function and the arguments. This helps immensely in understanding the code. You can use CamelCase or, for a somewhat more retro look, underscores for your names.
  • Does it matter where in your script the functions are defined, relative to where they are called? Could they be defined in a separate script element or linked script? Experiment.
  • Variable scoping problems are the source of many, many Javascript errors. Be very careful with variable declarations (var statements) to minimize problems.

[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: Monday, 18-Mar-2013 10:39:05 EDT

Department of Computer Science · University of Rochester
734 Computer Studies Bldg. · P.O. Box 270226 · Rochester, NY 14627
tel: 585 275-5671 · fax: 585 273-4556 · info@cs.rochester.edu
Hajim School of Engineering and Applied Sciences
[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]