# Algebra 1 – Lesson 1

1April 7, 2013 by Meghan Riling

Slideshow

CODE A

alert(“Hello!”)

CODE B

x = prompt(“What’s your name?”)

#alert1:

alert(x)

#alert2:

alert(“Hello, ” + x)

y = prompt(“What is your favorite color?”)

#alert3:

alert(“Your favorite color is ” + y)

#alert4:

alert(“I like ” + y + “, too.”)

z = prompt(“How old are you?”)

#alert5

alert( )

#alert6

alert( )

CODE C

x = parseInt(prompt(“Give me a number.”))

y = parseInt(prompt(“Give me another number.”))

#Find the sum

a = x + y

alert(“The sum of the numbers is ” + a)

#Find the product

b =

alert(“The product of the numbers is ” + b)

#Find the difference

c =

alert(“The difference between the numbers is ” + c)

#Find the sum of the square roots

sqRootOfx =

sqRootOfy =

d = sqRootOfx + sqRootOfy

alert(“The sum of the square roots is ” + d)

#Raise one number to the other one

e =

alert(“When you raise your first number to your second, you get ” + e)

CODE D

a = parseInt(prompt(“Type a value of a.”))

b = parseInt(prompt(“Type a value of b.”))

c = parseInt(prompt(“Type a value of c.”))

#a^2 – b

d =

alert(“a squared minus b is ” + d)

#square root of (c + d)

#add them up:

e =

#take the square root:

f =

alert(“The square root of c plus d is ” + f)

#raise a to b, and then to c

#raise a to b

g =

#raise ‘g’ to c

h =

alert(“a raised to b, then raised to c is ” + h)

[…] entry on my programming club blog with code to copy (lesson 1 and lesson […]