Introduction To Programming
10-152-310

Learning Plan 3 : Math and Operators

Student

  • Name:
  • Section:
  • Email:

Lab Steps

  • Open this file in your browser and Microsoft Visual Studio
  • Add your name, section, and email
  • Add code after the line: YOUR CODE STARTS AFTER THIS LINE: to complete this lab.
  • Your output should look like the Example Output below.
  • Variable declarations section
    1. Write a comment that identifies this coding section.
    2. Add the following variables:
      1. results1
      2. results2
      3. results3
      4. results4
      5. results5
      6. results6
      7. results7
      8. results8
      9. results9
      10. results10
  • Assignments section - No assignments section this time! They will get values in the calculations section.
  • Calculations section
    1. Write a comment that identifies this coding section.
    2. Perform the following calculations and assign the results to the corresponding "numberx" variable. The calculated value must be what is indicated after each step. Add parentheses to get the correct results.
    3. Here's how to do the first one:
      1. results1 = (25 * 10) / 2;
    4. The calculations:
      1. 25 * 10 / 2 --> 125
      2. 3 + 4 * 5 --> 23
      3. 3 + 4 * 5 --> 35
      4. 1 + 2 + 3 - 4 + 5 --> 7
      5. 1 + 2 + 3 - 4 + 5 --> -3
      6. 20 * 10 / 2 --> 100
      7. 2 / 3 * 3 * 3 --> 6
      8. 2 / 3 * 3 * 3 --> 0.666666666666667
      9. 2 / 3 * 3 * 3 --> 0.0740740740740741
      10. 2 * 2 - 2 --> 0
  • Output section
    1. Write a comment that identifies this coding section.
    2. Use a document.write(); to output the results. Add the calculation and the parentheses to the output. Here's how to do the first one:
      1. document.write("(25 * 10) / 2 --> " + results1 + "<br />");

Example Output

Without the parentheses that make it work.

        25 * 10 / 2 --> 125
        3 + 4 * 5 --> 23
        3 + 4 * 5 --> 35
        1 + 2 + 3 - 4 + 5 --> 7
        1 + 2 + 3 - 4 + 5 --> -3
        20 * 10 / 2 --> 100
        2 / 3 * 3 * 3 --> 6
        2 / 3 * 3 * 3 --> 0.6666666666666666
        2 / 3 * 3 * 3 --> 0.07407407407407407
        2 * 2 - 2 --> 0

Your Output: