Northcentral Technical College Introduction To Programming
10-152-310
Introduction to Programming with JavaScript NTC 10-152-310

Learning Plan 5 5.1 Lab 8

# 5.1 Lab 8

#### File: /Learning Plan 8/5.1lab8.html

### Student

- Name:
- Section:
- Email:

### Part 1 Lab Steps

1. Open this file in Firefox and Microsoft Visual Studio.
2. Add your name, section, and email
3. Open the file "/unit4/jsFiles/5.1lab8.js" in Microsoft Visual Studio.
4. Locate the function named "lab51_8()".
5. Add code after the line: `// PART 1: YOUR CODE STARTS AFTER THIS LINE:` to complete the lab part.
6. Variable declarations section
   1. Write a comment that identifies this coding section.
   2. Declare a `counter` variable.
   3. Declare a `loopMaximum` variable.
   4. Declare a `total` variable.
7. Assignments section
   1. Write a comment that identifies this coding section.
   2. Assign zero `(0)` to the `total` variable.
8. Processing Section
   1. Write a comment that identifies this coding section.
   2. Ask the user to enter the number of times they would like to loop and assign the entry to the `maximumLoop` variable.
   3. Convert the entered value to a number.
   4. Using a `for` loop perform the following the number of times that the user entered. For example, if the user entered 5 then loop 5 times.
   5. In the parentheses of the `for` loop perform the following:
      1. In the initialization section, assign one `(1)` to `counter` variable.
      2. In the boolean section check if the `counter` variable is less than or equal to the `loopMaximum` variable.
      3. In the increment section, increment the `counter` variable.
   6. In the `for` loop:
      1. Add the counter variable into the `total` variable. Use the compound operator `+=`.
      2. Write the `counter` variable and the `total` variable to the page as in the sample output.
   7. After the loop is done, write the total to the page as in the sample.

#### Sample Part 1 Output:

    In loop 1 the total is 1.
    In loop 2 the total is 3.
    In loop 3 the total is 6.
    In loop 4 the total is 10.
    In loop 5 the total is 15.

    The final total is 15.

### Your Output:

## Part 2 Lab Steps

1. Locate the function named "lab51_8Part2()".
2. Add code after the line: `// PART 2: YOUR CODE STARTS AFTER THIS LINE:` to complete the exercise from the program statement.

### Part 2 Problem Statement

> Write a program that will output 100 lines. Each line will be the number 1,000 divided by the number of the line. The first line of output will be, "1000 / 1 = 1000". The second line will be, "1000 / 2 = 500" and so on though 100 lines. Format the output as in the partial sample output. Use a `for` loop for this part.

#### Sample Part 2 Output (Partial):

    1000 / 1 = 1000
    1000 / 2 = 500
    1000 / 3 = 333.3333333333333
    1000 / 4 = 250
    1000 / 5 = 200
    1000 / 6 = 166.66666666666666
    ...
    1000 / 99 = 10.1010101010101
    1000 / 100 = 10

### Part 2 Program Planning Lists

- In the following pre tag, write the three planning lists based on the verbs and nouns you see in the problem statement.

    The List of Input Variables:

    The List of Output Variables:

    The Process Checklist:

### Part 2 Test Plan

    TEST PLAN:

    Test Case 1:
        Inputs:

        Expected Results:

    Test Case 2:
        Inputs:

        Expected Results:

    Test Case 3:
        Inputs:

        Expected Results:

### Your Part 2 Output:

### 5.1 Assignment 2

- 5.1 Assignment 2