Introduction To Programming
10-152-310

Learning Plan 2 : Variables and Data Types

Student

  • Name:
  • Section:
  • Email:

Part 1

  • Open this file in your browser and Microsoft Visual Studio
  • Add your name, section, and email
  • After the line: // PART 1: YOUR CODE STARTS AFTER THIS LINE:
    • Create a variable named apples.
    • Create a variable named oranges.
    • Assign the number 10 to the apples variable.
    • Assign the number 7 to the oranges variable.
    • Output the variables with some text.
    • You have to use the variables and not type the actual numbers when you output the above text. (Hint: you will need multiple document.write(); statements.)
  • Sample Output:
    I have 10 apples.
    I have 7 oranges.
  • You have to output some text, then a number, then some text. How do we do that? What will the output be?
                    
                

Your Part 1 Output:

        
        

Part 2

  • Open this file in your browser and Microsoft Visual Studio
  • After the line: // PART 2: YOUR CODE STARTS AFTER THIS LINE:
    • In the coding section below, create these variables:
      • a variable that holds a page count. put the number 100 in it
      • a variable that holds another page count, put the number 200 in it
      • a variable that holds the total of both page counts.
    • Assign the number 100 to the first page count variable.
    • Assign the number 200 to the second page count variable.
    • Add the two variables together and put the total in the total variable.
  • Create output that looks like this:
    Book one has 100 pages.
    Book two has 200 pages.
    There are a total of 300 pages.
  • You can't just type this in! You have to use the variables and a little math.

Your Part 2 Output:

			
        

What You Did

You practiced creating some JavaScript number variables and then displaying their values on the lab page. You also guessed at how to add two numbers together. We're you right?