CSC 160 - Computer Programming for Non-majors

Assignment #2: Averaging 5 numbers

Due Tues., September 21, 2010

Given the program that we developed in class that allows a user to average any 3 numbers that they enter, change the program so it will averaage any 5 numbers that the user enters.

You will submit the listing as the assignment.

<html>
  <head>
    <title>CSC 160 Lab Exercise #1</title>
  </head>

  <body>
    <script type="text/javascript">
      // Your name goes here

      var sum, average;
      var value1, value2, value3;

      value1 = parseInt(prompt("What is the first value\t?", 0));
      value2 = parseInt(prompt("What is the second value\t?", 0));
      value3 = parseInt(prompt("What is the third value\t?", 0))

      sum = value1 + value2 + value3;
      average = sum / 3;
      alert("The average is " + average);

    </script>
  </body>
</html>

[Back to the Lab Assignment List]