Exercise 1 Using Boolean variables, incorporating JavaScript code into your HTML webpage and using the document object

Size: px
Start display at page:

Download "Exercise 1 Using Boolean variables, incorporating JavaScript code into your HTML webpage and using the document object"

Transcription

1 CS1046 Lab 5 Timing: This lab should take you approximately 2 hours. Objectives: By the end of this lab you should be able to: Recognize a Boolean variable and identify the two values it can take Calculate the value in a Boolean expression Identify the 8 comparison operators Identify the 3 logical operators Label/identify the parts of an IF statement Determine when an IF statement should be required Trace a series of statements that use IF statements, including nested IF statements Write a valid IF statement Recognize the parts of a SWITCH statement Trace a switch statement Write a valid switch statement Determine when a switch statement should be used Exercise 1 Using Boolean variables, incorporating JavaScript code into your HTML webpage and using the document object One of the most basic and useful tools a carpenter has is a hammer. For a programmer, one of the most useful tools he/she has is an If statement. In this lab, you will learn how to use an If statement but first the Boolean variable must be introduced. A numeric variable can contain any number. A string variable can contain any combination of characters but a Boolean variable is different, in that it can ONLY contain one of two values: true or false. In this first exercise, we are going to use Boolean variables 1. Using the Chrome browser, go to this webpage: Right click and view the source for this page. 2. Create a new folder called lab5. Open Notepad and then save the file (in the lab5 folder) as yourwesternuseridlab5ex1a.html (eg. jsmith2lab5ex1a.html). It is important to save the file as an.html and not.txt file. Consult Lab 1 Exercise 5 if you have trouble. 1

2 3. Using the Chrome browser, go to this webpage: and copy the code into your lab5 folder. Do this by using Notepad to create a new file, paste the css code in and give this new file the name: lab5ex1.css 4. Notice that the html page only has a true radio button (a radio button is a special button that only lets you select one button out of a possible group of radio buttons). Go into and edit the html and add the tags to create another radio button (copy the first radio button line and paste it immediately below that line). The line should look like this: <input class="radiobut" value="t" name="q1" type="radio">true<br/> Change the value to f and the text before the <br/> to False. Also change the name to q2. Save your html file and reload it in the browser. Watch what happens, notice that you can now click on BOTH radio buttons. This is not what we wanted. With radio buttons, if you give them ALL the same name, then the radio buttons became a group and the user can only select one of them at a time. So change the name back to q1, save your html file and make sure it lets you only select ONE of the two radio buttons. 5. Now, double check that the <script> tag is there to point to the.js file. If it is not, then add the <script> tag to your html webpage just above the </head> tag and make the script tag point to a file called booleanfun.js. Save your html file. 6. A radio button is either selected or NOT selected. We want to test our radio buttons to see if each is selected or not selected. In Notepad, create a blank file called booleanfun.js and save it to your lab5 folder. Put the following function into the js file (HINT: REMEMBER, if you copy and paste the code below, rather than typing it in yourself, you might need to retype the single and double quotes as the fancy quotes are copied rather than the plain ones and you want the plain quotes!): function whowaschecked() { var radiobuttons; var firstbutton, secondbutton; radiobuttons = document.getelementsbyname('q1'); firstbutton=radiobuttons[0].checked; alert ( First button was checked: + firstbutton); 7. Let s take a closer look at the above function. Look at the line: radiobuttons = document.getelementsbyname('q1'); Because there is more than one radio button, we store the radio buttons in an array with the name q1 (make sure you remember the s on getelementsbyname). Now look at the line: firstbutton=radiobuttons[0].checked; As discussed last week, the first position in the array is located at index 0 and as a result, our first radio button will be at position [0]. To ascertain whether the firstbutton is checked or not, we look at the checked property for the first element. Next, we store this value inside a variable called firstbutton. A radio button is always in one of two states: either it is checked or it is not 2

3 checked (i.e. either TRUE or FALSE). Thus, the variable called firstbutton can only hold one of two values: true or false. firstbutton is now a Boolean variable. The.checked property of a radio button is also a Boolean variable as it is either true or false and can never be any other value other than true or false. (e.g. if can NOT hold values like or strings like Hello World ). 8. Go back into your html file; add the onclick call to call the above function from the Submit my answer Button. Save your html file and reload it. Try pressing your button after you have checked the first radio button and then when it is not checked to see the difference between the two. Make sure the alert is working properly (showing whether that first radio button was checked or not). 9. Now add the code to display if the second radio button is checked or not. The code should look almost identical to the code in Step 7 but use the variable secondbutton and remember that the second radio button will NOT be the [0]th element in the array. Remember to add the alert to see what value is in secondbutton. 10. Reload your html file and make sure that you button works properly. Congratulations, you now can: Create a group of radio buttons where only one button can be selected by giving them all the same name. List the values that a Boolean variable can accept Identify a Boolean variable Identify a Boolean property on an object such as.checked Exercise 2 Using the comparison operators and the logical operators and writing Boolean expressions 1. In this exercise, you will use the Boolean variable in more complex situations. Using the Chrome browser, go to this webpage: Right click and view the source for this page. 2. Open Notepad and then save the html for the webpage above in a file (in the lab5 folder) as yourwesternuseridlab5ex1b.html (eg. jsmith2lab5ex1b.html). 3. Open a blank document in Notepad and save the blank file to your lab5 folder as booleanfuntwo.js and create a function called testing123 that looks like this: function testing123() { var myboolean; myboolean= true; alert(myboolean); 4. Save your.js file. Reload your.html file in the browser and click on the button on your html page and make sure the button pops up an alert that says true 3

4 5. Now change the line: myboolean= true; to myboolean= true ; 6. Save your.js file and reload your.html file 7. Try clicking on your button again. It may look like it is giving the same answer but in actuality the second time you clicked on the button, you were seeing a string with the value of the word: true, it was not a Boolean. A Boolean will never have quotes around it. In addition, true and false are keywords, so you cannot use them as variable names. 8. Now change the line: myboolean= true ; to myboolean= 45<38; 9. Save your.js file and then reload your html file. This time you should get a value of false. (Now myboolean is a Boolean again). It has the value false because we are saying: put the result of the expression 45 is less than 38 into the variable called myboolean. Since 45 is less than 38 is not true (i.e. it is false), it puts the value false into the variable. 45<38 is called a Boolean expression (because it results in a value of either true or false) and < is called a comparison operator. Just like x=2+3; is an arithmetic expression, the expression: x=(3>=4) is a Boolean expression. Arithmetic expressions always evaluate to numbers, while Boolean expressions always evaluate to either true or false. Change the line: myboolean= 45<38; to myboolean= 45<=48; This time 45<=48 is true, so it should return true. Sometimes brackets make it easier to read so you could put this instead: myboolean=(45<=48); 10. Remember that one equals sign (=) is the assignment operator. So age=50; means assign the value 50 to the variable age. Thus, if we want to check if two things are equal to each other (rather than less than like we did above) in a Boolean expression, we cannot use the equal sign because it already has another job, the job of assigning values to variable. So instead, we use double equals (==) to check if 2 things are equal to each other. Now change the assignment line for myboolean to: myboolean= (45==(42+3)); and check what value is returned. 11. Now change that line to: myboolean= (45!=(42+3)); and watch what happens.!= means NOT equal in JavaScript. Therefore, we are saying 45 is not equal to That statement is false, therefore false is returned. 4

5 12. Now change that line to: myboolean= (45=='45'); this is checking if the value 45 is equal to the string 45. JavaScript converts the string 45 to a value, so this expression evaluates to true. 13. Now change that line to: myboolean= (45==='45'); This one should return false. That is because === (3 equal signs) means Strict Equal To so it checks both the value and the data type as well. 14. There are 8 comparison operators in JavaScript: == (equal to)!= (not equal to) === (strict equal to)!== (strict not equal to) > (greater than) < (less than) >= (greater than or equal to) <= (less than or equal to) 15. These operators can be used in a variety of situations. For instance, as shown below, you might use them to check if someone can a pass a course based on their score for the course: var haspassed, score, barforpassing; haspassed = (score >=barforpassing); 16. Sometimes you might want to compare the results of more than one Boolean expression. For example you might have a situation where a student must get more than 45% on the final exam AND more than 60% on the major assignment to pass your course. So you would have: var examscore, majorassignmentscore; var haspassed; haspassed = (examscore>45) AND (majorassignmentscore>60); however in JavaScript, you cannot use the word AND to compare the two boolean expressions, instead you would write it like this: haspassed=(examscore>45) && (majorassignmentscore>60); So in JavaScript && means AND 17. Go back to your code and change the line: myboolean= (45==='45'); to myboolean= (45>42) && ( 3< 4); Save your.js file and reload your html file and see what result you get. Basically we are saying: is 45 less than 42 AND is 3 less than 4. Being that both of the conditions are true, the statement evaluates to true 5

6 Now change that line to: myboolean= (45>42) && ( 3> 4); and see what happens. If either condition is false on either side of the &&, then the whole expression is false. So: true&&true will return true true&&false will return false false&&true will return false false&&false will return false 18. Imagine now that someone will pass your course if they get either more than 80 on the final exam OR they get more than 70 on the major assignment. Only one of those has to be true for your student to pass your course. For example: var examscore, majorassignmentscore; var haspassed; haspassed = (examscore>80) OR (majorassignmentscore>70); however in JavaScript, you cannot use the word OR to compare the two Boolean expressions, instead you would write it like this: haspassed = (examscore>45) (majorassignmentscore>60); So, in JavaScript means OR 19. Change the line: myboolean= (45>42)&&(3>4); to myboolean= (45>42) (3>4); save your.js file and reload your html file and see what you get when you press the button. In the case of an OR ( ) if either expression on either side of the is true, then the whole expression is true, so: true true will return true true false will return true false true will return true false false will return false change the line to be this now: myboolean= (5!=5) (6>7); and see what value you get, does it match what you expected? Now imagine that, if a student doesn t pass, you need to print out a warning message. To show this message you might think of something like this: If NOT (haspassed) THEN alert ( you didn t pass the course ); In JavaScript, we do not use the word NOT, instead we use the symbol! as shown below. var sendwarning; sendwarning =!(score>50); 6

7 Remember that NOT false is true and NOT true is false, so if we had: var b1,b2; b1 = (10==(5+5)); b2 =!b1; then b1 will hold true and b2 will hold false. 20. Change the line: myboolean = (5!=5) (6>7); to myboolean =!(6>7); and save your.js file. Before proceeding to the next step, make sure you understand what value is returned and why that is the case. 21. In programming languages: a. && (and), b. (or) c.! (not) are called logical operators. NOTE: && and must have Booleans or Boolean expressions on either side of them and! must be followed by a Boolean expression. Thus, you cannot do something like this: var x, y, z; x = 2 && 4; because 2 and 4 are not Boolean expressions or Boolean variables, however you can do this: x = 2; y = (3<1); z= (x==3) && y; 22. Boolean expressions are used extensively when writing programs, they are used when you need to write an IF statement or a loop. In the next section, we will use Boolean expression to write IF statements. Congratulations, you now can: Write a Boolean expression and assign it to a Boolean variable Identify the 8 comparison operators used when writing Boolean expression Identify the 3 logical operators ( and (&&), or ( ) and not (!) ) Evaluate a Boolean expression to decide whether it will return true or false 7

8 Exercise 3 Using IF statements 1. IF statements are one of the most important statements in programming and the syntax for them was purposely chosen so that they look very similar to plain English. For example, you might in English have the sentence: If it is raining then I will need to tell my daughter she needs an umbrella otherwise I will need to remind her to bring sunscreen. In JavaScript, you could write the statement like this: rainingtoday = getweather(today); //returns true or false if (rainingtoday) { alert( You need an umbrella ); //end of then (true part) else { alert( You need sunscreen ); //end of else (false - otherwise part) So an IF statement needs a Boolean condition (or variable) that evaluates to true or false (in our raining example, this was the yellow part) and if the condition is true, the first part of the IF statement will be executed (i.e., the then part), otherwise if the condition is false then the second part (the else part) will be executed. 2. Now we are going to use a Boolean variable to practice with writing If statements. Using the Chrome browser, go to this webpage: Right click and view the source for this page. 3. Open Notepad and then save the html to a file (in the lab5 folder) called yourwesternuseridlab5ex3.html (eg. jsmith2lab5ex3.html). It is important to save the file as an.html and not.txt file. Consult Lab 1 Exercise 5 if you experience difficulty. 4. Open a new file in Notepad and save this file as ifonetwothree.js in your lab5 folder. Add the following code to the.js file: function testing123() { if (1 == 2) { alert ("Math has gone crazy, now 1 equals 2"); //end of if statement alert ("at the end of testing123"); //end of function 5. Save your.js file and then reload your.html file and click on the button to see what happens. Notice that the alert statement about Math going crazy never is executed, that is because 1 does not equal 2. Thus, the condition in the IF statement is always false, so the program jumps 8

9 PAST the IF curly braces (which indicates the beginning and ending of the true conditional part) and executes the line after the if closing curly brace. Also notice the indentation. Indentation is extremely important for IF statements, the indentation makes it easier to understand which statements are executed when the condition is true. Change your.js function to be this now: function testing123() { if (1 == 2) { alert ("Math has gone crazy, now 1 equals 2"); alert ("i am still inside the true part of the if"); //end of if alert ("I am outside of the if"); alert ("at the end of testing123"); // end of function 6. Save your.js file, reload your.html file and watch what happens when you click your button. 7. Now change the if (1==2) to if (1<= 2) and save your.js file and reload your html and watch what happens when you click on the button. Now because the condition is true, the first 2 alert statements get executed and then the last 2 alert statements get executed regardless of the condition. 8. Now change your function to this: function testing123() { if (1 <= 2) { alert ("Whew 1 is still less than 2"); alert ("i am still inside the true part of the if"); //end of true part else { alert ("Oh no, this is false"); alert ("I am still inside the if statement, but now in the false part of it"); //end of false (else) part alert ("I am outside of the if"); alert ("at the end of testing123"); // end of function 9. Save your.js file and reload, click on the button and watch what happens. Notice that again the first 2 statements get executed, but the 2 alert statements in the else block are skipped over. This is because this code inside the curly braces { and immediately after the else are only executed when the condition is false. Think of a condition that would return false and put it in the brackets () after the if, i.e. right here: if (1 <= 2) (change this to a expression that evaluates to false). Notice again that the else part of the if statement (the part in curly braces after the else keyword), is indented also. Make sure you ALWAYS indent the true part of your IF statement and the false part (the else part) of your IF statement. Indentation makes IF statements easier to read and understand for programmers 9

10 (although the computer doesn t really care if you indent or not). Then save your.js file and make sure that only the else statements are executed and not the first part (i.e., the statements which are within the curly braces for the true). You don t HAVE to have an else on your IF statements, but sometimes you might need one. Congratulations, you now can: Create a syntactically correct IF statement Determine which part of an IF statement will be executed based on the Boolean condition Identify the statements that will be executed if the condition is true Identify the statements that will be executed if the condition is false (the else part) Identify the end of the IF statement Exercise 4 Using nested if statements and using the if statement in a real world scenario Making a High Low Game 1. Now we are going to use a Boolean variable in a real world scenario. Using the Chrome browser, go to this webpage: Right click and view the source for this page. 2. Open Notepad and then save the html for the above in a file (in the lab5 folder) as yourwesternuseridlab5ex4.html (eg. jsmith2lab5ex4.html). 3. Open the file: and save it as lab5ex4.css to your lab5 folder. 4. Load the.html file into the Chrome browser and see what the page looks like. We are going to write the code that will generate a random number between 1 and 10 and then allow the user to enter guesses until the user gets the correct answer. 5. Open Notepad and create a new file in the folder lab5 called highlowgame.js 6. First we need to generate a random number when the webpage is loaded. The original random number we generate has to be available for the entire time the page is displayed so we will make it a global variable. At the top of your.js file, NOT in a function, declare a variable called theanswer 7. Create a function called generatetheanswer() that generates a random number between 1 and 10 and stores the number in the variable called theanswer. Just for testing purposes, right after you generate the random number, put an alert statement that shows what is stored in theanswer. Save your.js file. 8. Next, in your.html file, we are going to add a call to the function generatetheanswer() WHEN the webpage loads. To do this, go to the <body> tag and change it so it looks like this: <body onload="generatetheanswer();"> 9. Now save your.html file and reload it. Make sure you can see the random number that your page is generating. Make sure it is a number between 1 and 10. If nothing is happening, try 10

11 going to Settings in Chrome, then More Tools, then Developer Tools to see if you can find any errors that may exist. 10. If you are still experiencing problems, edit your.js file so that it looks similar to this: var theanswer; // generate the number that the user must guess function generatetheanswer() { theanswer=math.floor(math.random() * (10-1) + 1); alert (theanswer); 11. Now we are going to write the code to check the user s guess. We will make another function called checktheguess(). Inside this function we will first declare a variable called theguess and assign it to the value of the element with the ID of guess (this is the textbox). This will put the value the user typed into the textbox, into the variable theguess. Put an alert temporarily to see if you are getting the guess correctly. Your code should look like this: function checktheguess() { var theguess; //holds users guess theguess=document.getelementbyid('guess').value*1; alert(theguess); 12. Now go back to your html code and add the onclick() to the <button> tag so that when the user clicks the button, it calls the function checktheguess(); Save your html file and make sure it works (make sure the alert for the answer is popping up and the alert for the user s guess in the text box is popping up) 13. Now go back to your.js code and remove the alert that is displaying the guess. Now we are going to start using IF statements. Firstly we will add an IF statement to ascertain whether the guess is too large, and if so, we will alert the user. Your function should now look like this: function checktheguess() { var theguess; //holds users guess theguess=document.getelementbyid('guess').value*1; if (theguess > theanswer) { alert( Your guess was too high. ); 14. Now write the IF statement that comes after the first one that will check if the users guess was too low. Save your.js file 15. Reload your html file and see if the check for high and low is working. After you have that working, add a third if statement that will check if theguess was equal to theanswer and if so, print out a message (alert) like Congratulations, you win! 11

12 16. Save your.js file and make sure your game works. Your.js code should look similar to this: var theanswer; // generate the number that the user must guess function generatetheanswer() { theanswer=math.floor(math.random() * (10-1) + 1); alert (theanswer); //function to check the users guess against the answer function checktheguess() { var theguess; //holds users guess theguess=document.getelementbyid('guess').value*1; if (theguess > theanswer) { alert( Your guess was too high. ); if (theguess < theanswer) { alter( Your guess was too low. ); if (theguess == theanswer) { alter( Congrats, you win. ); 17. The only problem now is that we are letting the user have lots of guesses. Maybe we only want the user to get 3 tries to get the correct answer. Declare another GLOBAL variable called numoftries (since we do not want it reset every time the user presses the button) at the top of the.js file. In the generatetheanswer() function, set the numoftries to zero as the user hasn t guessed when the page loads. In the IF statement for too high and the IF statement for too low, add one to the variable, because if these statements execute, then the user has used a turn. The code for your ifs should look similar to this: if (theguess > theanswer) { numoftries = numoftries+1; alert ("Your guess was too high"); 18. There are many ways we could check to see if the user has run out of guesses, here is one way you could handle it: if ((theguess == theanswer) && (numoftries<3)) { alert ("You Win"); 12

13 19. Save your.js file and reload your html file and make sure the user has to guess the number in 3 or less tries. 20. The only problem with our program now is that if the user guesses 4 or 5 times, it will still say Too High or Too Low. Maybe at this point, we just want to tell them that they cannot guess anymore. In order to do that, we are going to use a NESTED IF STATEMENT (i.e., an if statement inside of another if statement). Before we do anything in the function, we are going to use an IF statement to see if we still have guesses available, if we do then we will do the other ifs, otherwise we will output a message telling the user that he/she is out of guesses. The code will look like this (the red code is the outer if and the blue is the inner if): var theanswer; var numoftries; // generate the number that the user must guess function generatetheanswer() { numoftries=0; theanswer=math.floor(math.random() * (10-1) + 1); alert (theanswer); //function to check the user s guess against the answer function checktheguess() { var theguess; //holds users guess theguess=document.getelementbyid('guess').value * 1; if (numoftries < 3) { //allow them to keep guessing as they still have tries if (theguess > theanswer) { numoftries=numoftries+1; alert ("Too High"); //end of first INNER if if (theguess < theanswer) { numoftries=numoftries+1; alert ("Too Low"); //end of second INNER if if (theguess == theanswer) { alert ("You Win"); //end of third INNER if //end of true part for OUTER if else { alert("sorry, you have run out of tries."); //end of else for OUTER if //end of function 21. See if you can now add the code to let the user know the number of guesses he/she has left BEFORE he/she runs out of the 3 guesses. 13

14 22. Save the.js file and.html file Congratulations, you now can: Write a nested if statement Create a very simple game that runs in a browser! Exercise 5 Using Switch statements 1. Using the Chrome browser, go to this webpage: View the source and copy it, open Notepad and then save the.html (in the lab5 folder) as yourwesternuseridlab5ex5.html (eg. jsmith2lab5ex5.html). 2. Using the Chrome browser, go to this webpage: and copy that code into your lab5 folder. Use Notepad to create a new file, paste the css code in and give this new file the name: lab5ex5.css 3. Reload the html page in Chrome. In this exercise, we are going to write code that will allow us to change the colours of our webpage based on a colour entered into the textbox by the user. 4. In Notepad, create a new file and save it with the name colourmypage.js in your lab5 folder. We could choose to change the colours just using IF statement. Let s do that first. Create a function called changethecolor(). In the function, the first thing we are going to do is check what colour the user typed in and change it to lowercase using a predefined function called tolowercase(); Type in the following code: //change the color of the pieces of our webpage function changethecolor() { var desiredcolor; desiredcolor=document.getelementbyid('colortext').value; desiredcolor=desiredcolor.tolowercase(); alert(desiredcolor); //end of function 5. Save your file, reload your html file, type a colour (with some upper case letters in it) into the textbox, click on the button and make sure the function outputs the colour name in lowercase. 14

15 6. Replace the line: alert(desiredcolor); with the lines: if (desiredcolor=='green') { document.body.style.backgroundcolor="lightgreen"; document.getelementbyid("mybutton").style.backgroundcolor="darkolivegreen"; else if (desiredcolor == 'yellow') { document.body.style.backgroundcolor="gold"; document.getelementbyid("mybutton").style.backgroundcolor="palegoldenrod"; 7. Save your.js file and reload your.html file again. Try typing yellow into the textbox and watch what happens. We could continue using IF statements to do this but JavaScript provides us with an alternative statement to perform this type of checking. This statement is called a SWITCH statement. Switch statements are ideal when we need to check the value of a single variable, in our case, desiredcolor, to see if it is equal to a value, in our case a colour name. A switch statement starts with a variable called the switch value and checks each case to see if the variable equals this value. If it finds a case that DOES equal the value, then it executes the switch code up until it hits a break statement. Once it hits a break statement, it jumps to the end of the switch statement. Change your function, so that it looks like this now: //change the color of the pieces of our webpage function changethecolor() { var desiredcolor; desiredcolor=document.getelementbyid('colortext').value; desiredcolor=desiredcolor.tolowercase(); switch (desiredcolor) { case green : document.body.style.backgroundcolor="lightgreen"; document.getelementbyid("mybutton").style.backgroundcolor="darkolivegreen"; break; case yellow : document.body.style.backgroundcolor="gold"; document.getelementbyid("mybutton").style.backgroundcolor="palegoldenrod"; break; //end of switch statement //end of function 15

16 8. Save your.js file and reload your html file and test it. NOTE a switch statement is only useful if you are just testing ONE variable (thus, a condition like if((grade>50) && (assignment1<80)) could not be translated into a switch statement because you need to check both the grade and the assignment1 variables). NOTE the general syntax for a JavaScript switch statement is: switch (variabletobetested) { case value1: statement(s); break; case value2: statement(s); break; case // end of switch 9. Now add another case to check to see if desiredcolor is blue. If so, change the body background to CornflowerBlue and the button background to Navy. Save your.js file and make sure the webpage still works when the user enters blue. 10. If the user enters a colour we don t know or leaves the textbox empty, we can still use the switch statement to catch that by using the default statement. Right before the line: //end of switch statement add the following lines: default: document.body.style.backgroundcolor="white"; alert ("Sometimes I don't know my favourite colour either!"); break; 11. Save the.js file and try typing in the colour seafoam into the html webpage. Press the button and observe what happens. 12. Add a case ABOVE the default: statement to check for YOUR favourite colour and then set the page (body) background and button background to shades of those colours using this webpage to find some shades you like: Do not forget to include the break; statement (try intentionally forgetting it and watch what happens, if you don t want the default executed, you need the break statement). 13. Finally, for each case statement, add a line that will change the background colour of the textbox to the same colour as the button was changed to. Look at the html to find the Id for the textbox. The code is EXTREMELY similar to the code for changing the button. 14. Save and test your work. 16

17 Congratulations, now you can: Identify the parts of a switch statement (the switch variable, the opening of the statement the opening curly brace, the cases, the breaks to end the cases, the default and the closing curly brace for the switch statement) Write a case statement for a switch variable Write a default and some statements, for actions to happen when nothing matches the switch variable Identify the flow of control if the programmer forgets to include the break at the end of a case in a switch statement HAND THIS WORK INTO OWL IN ORDER TO GET YOUR LAB MARK. 1. Go into owl, under assignments and for the Lab5 Activities assignment, submit the 2 files you created for Exercise 5 the file youruseridlab5ex5.html and the file colourmypage.js so that we can check that your code is working properly. 17

CS1046 Lab 4. Timing: This lab should take you 85 to 130 minutes. Objectives: By the end of this lab you should be able to:

CS1046 Lab 4. Timing: This lab should take you 85 to 130 minutes. Objectives: By the end of this lab you should be able to: CS1046 Lab 4 Timing: This lab should take you 85 to 130 minutes. Objectives: By the end of this lab you should be able to: Define the terms: function, calling and user-defined function and predefined function

More information

Controlled Assessment Task. Question 1 - Describe how this HTML code produces the form displayed in the browser.

Controlled Assessment Task. Question 1 - Describe how this HTML code produces the form displayed in the browser. Controlled Assessment Task Question 1 - Describe how this HTML code produces the form displayed in the browser. The form s code is displayed in the tags; this creates the object which is the visible

More information

BEGINNER PHP Table of Contents

BEGINNER PHP Table of Contents Table of Contents 4 5 6 7 8 9 0 Introduction Getting Setup Your first PHP webpage Working with text Talking to the user Comparison & If statements If & Else Cleaning up the game Remembering values Finishing

More information

CMPT 100 : INTRODUCTION TO

CMPT 100 : INTRODUCTION TO CMPT 100 : INTRODUCTION TO COMPUTING TUTORIAL #5 : JAVASCRIPT 2 GUESSING GAME 1 By Wendy Sharpe BEFORE WE GET STARTED... If you have not been to the first tutorial introduction JavaScript then you must

More information

CMSC 201 Fall 2016 Lab 09 Advanced Debugging

CMSC 201 Fall 2016 Lab 09 Advanced Debugging CMSC 201 Fall 2016 Lab 09 Advanced Debugging Assignment: Lab 09 Advanced Debugging Due Date: During discussion Value: 10 points Part 1: Introduction to Errors Throughout this semester, we have been working

More information

The name of our class will be Yo. Type that in where it says Class Name. Don t hit the OK button yet.

The name of our class will be Yo. Type that in where it says Class Name. Don t hit the OK button yet. Mr G s Java Jive #2: Yo! Our First Program With this handout you ll write your first program, which we ll call Yo. Programs, Classes, and Objects, Oh My! People regularly refer to Java as a language that

More information

ORB Education Quality Teaching Resources

ORB Education Quality Teaching Resources JavaScript is one of the programming languages that make things happen in a web page. It is a fantastic way for students to get to grips with some of the basics of programming, whilst opening the door

More information

Beginning HTML. The Nuts and Bolts of building Web pages.

Beginning HTML. The Nuts and Bolts of building Web pages. Beginning HTML The Nuts and Bolts of building Web pages. Overview Today we will cover: 1. what is HTML and what is it not? Building a simple webpage Getting that online. What is HTML? The language of the

More information

Client Side JavaScript and AJAX

Client Side JavaScript and AJAX Client Side JavaScript and AJAX Client side javascript is JavaScript that runs in the browsers of people using your site. So far all the JavaScript code we've written runs on our node.js server. This is

More information

Boolean Expressions. Is Equal and Is Not Equal

Boolean Expressions. Is Equal and Is Not Equal 3 MAKING CHOICES Now that we ve covered how to create constants and variables, you re ready to learn how to tell your computer to make choices. This chapter is about controlling the flow of a computer

More information

Web Programming and Design. MPT Junior Cycle Tutor: Tamara Demonstrators: Aaron, Marion, Hugh

Web Programming and Design. MPT Junior Cycle Tutor: Tamara Demonstrators: Aaron, Marion, Hugh Web Programming and Design MPT Junior Cycle Tutor: Tamara Demonstrators: Aaron, Marion, Hugh Plan for the next 5 weeks: Introduction to HTML tags, creating our template file Introduction to CSS and style

More information

CSCI 1100L: Topics in Computing Lab Lab 11: Programming with Scratch

CSCI 1100L: Topics in Computing Lab Lab 11: Programming with Scratch CSCI 1100L: Topics in Computing Lab Lab 11: Programming with Scratch Purpose: We will take a look at programming this week using a language called Scratch. Scratch is a programming language that was developed

More information

JavaScript Basics. The Big Picture

JavaScript Basics. The Big Picture JavaScript Basics At this point, you should have reached a certain comfort level with typing and running JavaScript code assuming, of course, that someone has already written it for you This handout aims

More information

(Refer Slide Time: 01:40)

(Refer Slide Time: 01:40) Internet Technology Prof. Indranil Sengupta Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Lecture No #25 Javascript Part I Today will be talking about a language

More information

Manju Muralidharan Priya. CS4PM Web Aesthetics and Development WEEK 11

Manju Muralidharan Priya. CS4PM Web Aesthetics and Development WEEK 11 CS4PM Web Aesthetics and Development WEEK 11 Objective: Understand basics of JScript Outline: a. Basics of JScript Reading: Refer to w3schools websites and use the TRY IT YOURSELF editor and play with

More information

Programming Lab 1 (JS Hwk 3) Due Thursday, April 28

Programming Lab 1 (JS Hwk 3) Due Thursday, April 28 Programming Lab 1 (JS Hwk 3) Due Thursday, April 28 Lab You may work with partners for these problems. Make sure you put BOTH names on the problems. Create a folder named JSLab3, and place all of the web

More information

CS 1110, LAB 1: PYTHON EXPRESSIONS.

CS 1110, LAB 1: PYTHON EXPRESSIONS. CS 1110, LAB 1: PYTHON EXPRESSIONS Name: Net-ID: There is an online version of these instructions at http://www.cs.cornell.edu/courses/cs1110/2012fa/labs/lab1 You may wish to use that version of the instructions.

More information

CS Multimedia and Communications REMEMBER TO BRING YOUR MEMORY STICK TO EVERY LAB!

CS Multimedia and Communications REMEMBER TO BRING YOUR MEMORY STICK TO EVERY LAB! CS 1033 Multimedia and Communications REMEMBER TO BRING YOUR MEMORY STICK TO EVERY LAB! Lab 06: Introduction to KompoZer (Website Design - Part 3 of 3) Lab 6 Tutorial 1 In this lab we are going to learn

More information

Project 2: After Image

Project 2: After Image Project 2: After Image FIT100 Winter 2007 Have you ever stared at an image and noticed that when it disappeared, a shadow of the image was still briefly visible. This is called an after image, and we experiment

More information

Boolean Expressions. Is Equal and Is Not Equal

Boolean Expressions. Is Equal and Is Not Equal 3 MAKING CHOICES ow that we ve covered how to create constants and variables, you re ready to learn how to tell your computer to make choices. This chapter is about controlling the flow of a computer program

More information

Programming language components

Programming language components Programming language components syntax: grammar rules for defining legal statements what's grammatically legal? how are things built up from smaller things? semantics: what things mean what do they compute?

More information

JQuery and Javascript

JQuery and Javascript JQuery and Javascript Javascript - a programming language to perform calculations/ manipulate HTML and CSS/ make a web page interactive JQuery - a javascript framework to help manipulate HTML and CSS JQuery

More information

Hello World! Computer Programming for Kids and Other Beginners. Chapter 1. by Warren Sande and Carter Sande. Copyright 2009 Manning Publications

Hello World! Computer Programming for Kids and Other Beginners. Chapter 1. by Warren Sande and Carter Sande. Copyright 2009 Manning Publications Hello World! Computer Programming for Kids and Other Beginners by Warren Sande and Carter Sande Chapter 1 Copyright 2009 Manning Publications brief contents Preface xiii Acknowledgments xix About this

More information

What is PHP? [1] Figure 1 [1]

What is PHP? [1] Figure 1 [1] PHP What is PHP? [1] PHP is an acronym for "PHP: Hypertext Preprocessor" PHP is a widely-used, open source scripting language PHP scripts are executed on the server PHP is free to download and use Figure

More information

Let's Look Back. We talked about how to create a form in HTML. Forms are one way to interact with users

Let's Look Back. We talked about how to create a form in HTML. Forms are one way to interact with users Introduction to PHP Let's Look Back We talked about how to create a form in HTML Forms are one way to interact with users Users can enter information into forms which can be used by you (programmer) We

More information

CpSc 111 Lab 5 Conditional Statements, Loops, the Math Library, and Redirecting Input

CpSc 111 Lab 5 Conditional Statements, Loops, the Math Library, and Redirecting Input CpSc Lab 5 Conditional Statements, Loops, the Math Library, and Redirecting Input Overview For this lab, you will use: one or more of the conditional statements explained below scanf() or fscanf() to read

More information

Working with JavaScript

Working with JavaScript Working with JavaScript Creating a Programmable Web Page for North Pole Novelties 1 Objectives Introducing JavaScript Inserting JavaScript into a Web Page File Writing Output to the Web Page 2 Objectives

More information

Repetition Structures

Repetition Structures Repetition Structures Chapter 5 Fall 2016, CSUS Introduction to Repetition Structures Chapter 5.1 1 Introduction to Repetition Structures A repetition structure causes a statement or set of statements

More information

Condition-Controlled Loop. Condition-Controlled Loop. If Statement. Various Forms. Conditional-Controlled Loop. Loop Caution.

Condition-Controlled Loop. Condition-Controlled Loop. If Statement. Various Forms. Conditional-Controlled Loop. Loop Caution. Repetition Structures Introduction to Repetition Structures Chapter 5 Spring 2016, CSUS Chapter 5.1 Introduction to Repetition Structures The Problems with Duplicate Code A repetition structure causes

More information

EECS 183. Week 3 - Diana Gage. www-personal.umich.edu/ ~drgage

EECS 183. Week 3 - Diana Gage. www-personal.umich.edu/ ~drgage EECS 183 Week 3 - Diana Gage www-personal.umich.edu/ ~drgage Upcoming Deadlines Lab 3 and Assignment 3 due October 2 nd (this Friday) Project 2 will be due October 6 th (a week from Friday) Get started

More information

Task 1. Set up Coursework/Examination Weights

Task 1. Set up Coursework/Examination Weights Lab02 Page 1 of 6 Lab 02 Student Mark Calculation HTML table button textbox JavaScript comments function parameter and argument variable naming Number().toFixed() Introduction In this lab you will create

More information

Lesson 7: If Statement and Comparison Operators

Lesson 7: If Statement and Comparison Operators JavaScript 101 7-1 Lesson 7: If Statement and Comparison Operators OBJECTIVES: In this lesson you will learn about Branching or conditional satements How to use the comparison operators: ==,!=, < ,

More information

Section 1. How to use Brackets to develop JavaScript applications

Section 1. How to use Brackets to develop JavaScript applications Section 1 How to use Brackets to develop JavaScript applications This document is a free download from Murach books. It is especially designed for people who are using Murach s JavaScript and jquery, because

More information

c122jan2714.notebook January 27, 2014

c122jan2714.notebook January 27, 2014 Internet Developer 1 Start here! 2 3 Right click on screen and select View page source if you are in Firefox tells the browser you are using html. Next we have the tag and at the

More information

Variables and Typing

Variables and Typing Variables and Typing Christopher M. Harden Contents 1 The basic workflow 2 2 Variables 3 2.1 Declaring a variable........................ 3 2.2 Assigning to a variable...................... 4 2.3 Other

More information

Chapter 3. More Flow of Control. Copyright 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Chapter 3. More Flow of Control. Copyright 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 3 More Flow of Control Overview 3.1 Using Boolean Expressions 3.2 Multiway Branches 3.3 More about C++ Loop Statements 3.4 Designing Loops Slide 3-3 Flow Of Control Flow of control refers to the

More information

Lab 8 CSE 3,Fall 2017

Lab 8 CSE 3,Fall 2017 Lab 8 CSE 3,Fall 2017 In this lab we are going to take what we have learned about both HTML and JavaScript and use it to create an attractive interactive page. Today we will create a web page that lets

More information

Control Structures. Code can be purely arithmetic assignments. At some point we will need some kind of control or decision making process to occur

Control Structures. Code can be purely arithmetic assignments. At some point we will need some kind of control or decision making process to occur Control Structures Code can be purely arithmetic assignments At some point we will need some kind of control or decision making process to occur C uses the if keyword as part of it s control structure

More information

Java Programming Fundamentals - Day Instructor: Jason Yoon Website:

Java Programming Fundamentals - Day Instructor: Jason Yoon Website: Java Programming Fundamentals - Day 1 07.09.2016 Instructor: Jason Yoon Website: http://mryoon.weebly.com Quick Advice Before We Get Started Java is not the same as javascript! Don t get them confused

More information

JavaScript Functions, Objects and Array

JavaScript Functions, Objects and Array JavaScript Functions, Objects and Array Defining a Function A definition starts with the word function. A name follows that must start with a letter or underscore, followed by any number of letters, digits,

More information

TOPIC 2 INTRODUCTION TO JAVA AND DR JAVA

TOPIC 2 INTRODUCTION TO JAVA AND DR JAVA 1 TOPIC 2 INTRODUCTION TO JAVA AND DR JAVA Notes adapted from Introduction to Computing and Programming with Java: A Multimedia Approach by M. Guzdial and B. Ericson, and instructor materials prepared

More information

Chapter 3 - Simple JavaScript - Programming Basics. Lesson 1 - JavaScript: What is it and what does it look like?

Chapter 3 - Simple JavaScript - Programming Basics. Lesson 1 - JavaScript: What is it and what does it look like? Chapter 3 - Simple JavaScript - Programming Basics Lesson 1 - JavaScript: What is it and what does it look like? PP presentation JavaScript.ppt. Lab 3.1. Lesson 2 - JavaScript Comments, document.write(),

More information

UNIT 3 SECTION 1 Answer the following questions Q.1: What is an editor? editor editor Q.2: What do you understand by a web browser?

UNIT 3 SECTION 1 Answer the following questions Q.1: What is an editor? editor editor Q.2: What do you understand by a web browser? UNIT 3 SECTION 1 Answer the following questions Q.1: What is an editor? A 1: A text editor is a program that helps you write plain text (without any formatting) and save it to a file. A good example is

More information

Lesson 5: Introduction to Events

Lesson 5: Introduction to Events JavaScript 101 5-1 Lesson 5: Introduction to Events OBJECTIVES: In this lesson you will learn about Event driven programming Events and event handlers The onclick event handler for hyperlinks The onclick

More information

Lesson 1: Writing Your First JavaScript

Lesson 1: Writing Your First JavaScript JavaScript 101 1-1 Lesson 1: Writing Your First JavaScript OBJECTIVES: In this lesson you will be taught how to Use the tag Insert JavaScript code in a Web page Hide your JavaScript

More information

Lab # 2. For today s lab:

Lab # 2. For today s lab: 1 ITI 1120 Lab # 2 Contributors: G. Arbez, M. Eid, D. Inkpen, A. Williams, D. Amyot 1 For today s lab: Go the course webpage Follow the links to the lab notes for Lab 2. Save all the java programs you

More information

Getting Started. Excerpted from Hello World! Computer Programming for Kids and Other Beginners

Getting Started. Excerpted from Hello World! Computer Programming for Kids and Other Beginners Getting Started Excerpted from Hello World! Computer Programming for Kids and Other Beginners EARLY ACCESS EDITION Warren D. Sande and Carter Sande MEAP Release: May 2008 Softbound print: November 2008

More information

CS 115 Lecture 8. Selection: the if statement. Neil Moore

CS 115 Lecture 8. Selection: the if statement. Neil Moore CS 115 Lecture 8 Selection: the if statement Neil Moore Department of Computer Science University of Kentucky Lexington, Kentucky 40506 neil@cs.uky.edu 24 September 2015 Selection Sometime we want to execute

More information

6.170 Laboratory in Software Engineering Java Style Guide. Overview. Descriptive names. Consistent indentation and spacing. Page 1 of 5.

6.170 Laboratory in Software Engineering Java Style Guide. Overview. Descriptive names. Consistent indentation and spacing. Page 1 of 5. Page 1 of 5 6.170 Laboratory in Software Engineering Java Style Guide Contents: Overview Descriptive names Consistent indentation and spacing Informative comments Commenting code TODO comments 6.170 Javadocs

More information

Enhancing Web Pages with JavaScript

Enhancing Web Pages with JavaScript Enhancing Web Pages with JavaScript Introduction In this Tour we will cover: o The basic concepts of programming o How those concepts are translated into JavaScript o How JavaScript can be used to enhance

More information

contain a geometry package, and so on). All Java classes should belong to a package, and you specify that package by typing:

contain a geometry package, and so on). All Java classes should belong to a package, and you specify that package by typing: Introduction to Java Welcome to the second CS15 lab! By now we've gone over objects, modeling, properties, attributes, and how to put all of these things together into Java classes. It's perfectly okay

More information

c122sep814.notebook September 08, 2014 All assignments should be sent to Backup please send a cc to this address

c122sep814.notebook September 08, 2014 All assignments should be sent to Backup please send a cc to this address All assignments should be sent to p.grocer@rcn.com Backup please send a cc to this address Note that I record classes and capture Smartboard notes. They are posted under audio and Smartboard under XHTML

More information

<script> function yourfirstfunc() { alert("hello World!") } </script>

<script> function yourfirstfunc() { alert(hello World!) } </script> JavaScript: Lesson 1 Terms: HTML: a mark-up language used for web pages (no power) CSS: a system for adding style to web pages css allows developers to choose how to style the html elements in a web page

More information

DECISION STRUCTURES: USING IF STATEMENTS IN JAVA

DECISION STRUCTURES: USING IF STATEMENTS IN JAVA DECISION STRUCTURES: USING IF STATEMENTS IN JAVA S o far all the programs we have created run straight through from start to finish, without making any decisions along the way. Many times, however, you

More information

1) Log on to the computer using your PU net ID and password.

1) Log on to the computer using your PU net ID and password. CS 150 Lab Logging on: 1) Log on to the computer using your PU net ID and password. Connecting to Winter: Winter is the computer science server where all your work will be stored. Remember, after you log

More information

Lab 1 Concert Ticket Calculator

Lab 1 Concert Ticket Calculator Lab 1 Concert Ticket Calculator Purpose To assess your ability to apply the knowledge and skills developed in weeks 1 through 3. Emphasis will be placed on the following learning outcomes: 1. Create and

More information

Intro to Programming. Unit 7. What is Programming? What is Programming? Intro to Programming

Intro to Programming. Unit 7. What is Programming? What is Programming? Intro to Programming Intro to Programming Unit 7 Intro to Programming 1 What is Programming? 1. Programming Languages 2. Markup vs. Programming 1. Introduction 2. Print Statement 3. Strings 4. Types and Values 5. Math Externals

More information

Programming Principles 1 (CSC131) & 2 (CSC132) Software usage guide

Programming Principles 1 (CSC131) & 2 (CSC132) Software usage guide School of Sciences Department of Computer Science and Engineering Programming Principles 1 (CSC131) & 2 (CSC132) Software usage guide WHAT SOFTWARE AM I GOING TO NEED/USE?... 3 WHERE DO I FIND THE SOFTWARE?...

More information

Text Input and Conditionals

Text Input and Conditionals Text Input and Conditionals Text Input Many programs allow the user to enter information, like a username and password. Python makes taking input from the user seamless with a single line of code: input()

More information

LOOPS. Repetition using the while statement

LOOPS. Repetition using the while statement 1 LOOPS Loops are an extremely useful feature in any programming language. They allow you to direct the computer to execute certain statements more than once. In Python, there are two kinds of loops: while

More information

CMSC 201 Fall 2018 Lab 04 While Loops

CMSC 201 Fall 2018 Lab 04 While Loops CMSC 201 Fall 2018 Lab 04 While Loops Assignment: Lab 04 While Loops Due Date: During discussion, September 24 th through September 27 th Value: 10 points (8 points during lab, 2 points for Pre Lab quiz)

More information

Advanced Web Tutorial 1 Editor Brackets / Visual Code

Advanced Web Tutorial 1 Editor Brackets / Visual Code Advanced Web Tutorial 1 Editor Brackets / Visual Code Goals Create a website showcasing the following techniques - Liquid Layout - Z-index - Visibility Website - Create a folder on the desktop called tutorial

More information

HTML/CSS Lesson Plans

HTML/CSS Lesson Plans HTML/CSS Lesson Plans Course Outline 8 lessons x 1 hour Class size: 15-25 students Age: 10-12 years Requirements Computer for each student (or pair) and a classroom projector Pencil and paper Internet

More information

LECTURE 08: INTRODUCTION TO HTML

LECTURE 08: INTRODUCTION TO HTML http://smtom.lecture.ub.ac.id/ Password: https://syukur16tom.wordpress.com/ Password: LECTURE 08: INTRODUCTION TO HTML We make a living by what we get, but we make a life by what we give. Winston Churchill

More information

[ the academy_of_code] Senior Beginners

[ the academy_of_code] Senior Beginners [ the academy_of_code] Senior Beginners 1 Drawing Circles First step open Processing Open Processing by clicking on the Processing icon (that s the white P on the blue background your teacher will tell

More information

c122mar413.notebook March 06, 2013

c122mar413.notebook March 06, 2013 These are the programs I am going to cover today. 1 2 Javascript is embedded in HTML. The document.write() will write the literal Hello World! to the web page document. Then the alert() puts out a pop

More information

JAVASCRIPT - CREATING A TOC

JAVASCRIPT - CREATING A TOC JAVASCRIPT - CREATING A TOC Problem specification - Adding a Table of Contents. The aim is to be able to show a complete novice to HTML, how to add a Table of Contents (TOC) to a page inside a pair of

More information

JS Lab 1: (Due Thurs, April 27)

JS Lab 1: (Due Thurs, April 27) JS Lab 1: (Due Thurs, April 27) For this lab, you may work with a partner, or you may work alone. If you choose a partner, this will be your partner for the final project. If you choose to do it with a

More information

Student, Perfect Final Exam May 25, 2006 ID: Exam No CS-081/Vickery Page 1 of 6

Student, Perfect Final Exam May 25, 2006 ID: Exam No CS-081/Vickery Page 1 of 6 Student, Perfect Final Exam May 25, 2006 ID: 9999. Exam No. 3193 CS-081/Vickery Page 1 of 6 NOTE: It is my policy to give a failing grade in the course to any student who either gives or receives aid on

More information

Relational & Logical Operators, if and switch Statements

Relational & Logical Operators, if and switch Statements 1 Relational & Logical Operators, if and switch Statements Topics Relational Operators and Expressions The if Statement The if- Statement Nesting of if- Statements switch Logical Operators and Expressions

More information

Chapter 3. More Flow of Control. Copyright 2008 Pearson Addison-Wesley. All rights reserved.

Chapter 3. More Flow of Control. Copyright 2008 Pearson Addison-Wesley. All rights reserved. Chapter 3 More Flow of Control Overview 3.1 Using Boolean Expressions 3.2 Multiway Branches 3.3 More about C++ Loop Statements 3.4 Designing Loops Slide 3-3 Flow Of Control Flow of control refers to the

More information

Definition: A data structure is a way of organizing data in a computer so that it can be used efficiently.

Definition: A data structure is a way of organizing data in a computer so that it can be used efficiently. The Science of Computing I Lesson 4: Introduction to Data Structures Living with Cyber Pillar: Data Structures The need for data structures The algorithms we design to solve problems rarely do so without

More information

Chapter 17. Fundamental Concepts Expressed in JavaScript

Chapter 17. Fundamental Concepts Expressed in JavaScript Chapter 17 Fundamental Concepts Expressed in JavaScript Learning Objectives Tell the difference between name, value, and variable List three basic data types and the rules for specifying them in a program

More information

If Statements, For Loops, Functions

If Statements, For Loops, Functions Fundamentals of Programming If Statements, For Loops, Functions Table of Contents Hello World Types of Variables Integers and Floats String Boolean Relational Operators Lists Conditionals If and Else Statements

More information

Software Design & Programming I

Software Design & Programming I Software Design & Programming I Starting Out with C++ (From Control Structures through Objects) 7th Edition Written by: Tony Gaddis Pearson - Addison Wesley ISBN: 13-978-0-132-57625-3 Chapter 4 Making

More information

CoderDojo Activity Cards: The Cards (Animation2.html): How to use: Student comes to mentor, and together they choose a card to do next.

CoderDojo Activity Cards: The Cards (Animation2.html): How to use: Student comes to mentor, and together they choose a card to do next. CoderDojo Activity Cards: How to use: Student comes to mentor, and together they choose a card to do next. The idea is always to choose a card that is interesting, and at the right level for the moment,

More information

Princess Nourah bint Abdulrahman University. Computer Sciences Department

Princess Nourah bint Abdulrahman University. Computer Sciences Department Princess Nourah bint Abdulrahman University 1 And use http://www.w3schools.com/ JavaScript Objectives Introduction to JavaScript Objects Data Variables Operators Types Functions Events 4 Why Study JavaScript?

More information

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 3: SEP. 13TH INSTRUCTOR: JIAYIN WANG

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 3: SEP. 13TH INSTRUCTOR: JIAYIN WANG CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 3: SEP. 13TH INSTRUCTOR: JIAYIN WANG 1 Notice Reading Assignment Chapter 1: Introduction to Java Programming Homework 1 It is due this coming Sunday

More information

This tutorial will teach you about operators. Operators are symbols that are used to represent an actions used in programming.

This tutorial will teach you about operators. Operators are symbols that are used to represent an actions used in programming. OPERATORS This tutorial will teach you about operators. s are symbols that are used to represent an actions used in programming. Here is the link to the tutorial on TouchDevelop: http://tdev.ly/qwausldq

More information

Section 0.3 The Order of Operations

Section 0.3 The Order of Operations Section 0.3 The Contents: Evaluating an Expression Grouping Symbols OPERATIONS The Distributive Property Answers Focus Exercises Let s be reminded of those operations seen thus far in the course: Operation

More information

Language Basics. /* The NUMBER GAME - User tries to guess a number between 1 and 10 */ /* Generate a random number between 1 and 10 */

Language Basics. /* The NUMBER GAME - User tries to guess a number between 1 and 10 */ /* Generate a random number between 1 and 10 */ Overview Language Basics This chapter describes the basic elements of Rexx. It discusses the simple components that make up the language. These include script structure, elements of the language, operators,

More information

5. Control Statements

5. Control Statements 5. Control Statements This section of the course will introduce you to the major control statements in C++. These control statements are used to specify the branching in an algorithm/recipe. Control statements

More information

Agenda. My Introduction. CIS 154 Javascript Programming

Agenda. My Introduction. CIS 154 Javascript Programming CIS 154 Javascript Programming Brad Rippe brippe@fullcoll.edu Agenda Brief Javascript Introduction Course Requirements Brief HTML review On to JavaScript Assignment 1 Due Next week Helpful Tools Questions/Comments

More information

COMP : Practical 8 ActionScript II: The If statement and Variables

COMP : Practical 8 ActionScript II: The If statement and Variables COMP126-2006: Practical 8 ActionScript II: The If statement and Variables The goal of this practical is to introduce the ActionScript if statement and variables. If statements allow us to write scripts

More information

Web Programming and Design. MPT Junior Cycle Tutor: Tamara Demonstrators: Aaron, Marion, Hugh

Web Programming and Design. MPT Junior Cycle Tutor: Tamara Demonstrators: Aaron, Marion, Hugh Web Programming and Design MPT Junior Cycle Tutor: Tamara Demonstrators: Aaron, Marion, Hugh Plan for the next 5 weeks: Introduction to HTML tags, creating our template file Introduction to CSS and style

More information

INTRODUCTION (1) Recognize HTML code (2) Understand the minimum requirements inside a HTML page (3) Know what the viewer sees and the system uses

INTRODUCTION (1) Recognize HTML code (2) Understand the minimum requirements inside a HTML page (3) Know what the viewer sees and the system uses Assignment Two: The Basic Web Code INTRODUCTION HTML (Hypertext Markup Language) In the previous assignment you learned that FTP was just another language that computers use to communicate. The same holds

More information

BB4W. KS3 Programming Workbook INTRODUCTION TO. BBC BASIC for Windows. Name: Class:

BB4W. KS3 Programming Workbook INTRODUCTION TO. BBC BASIC for Windows. Name: Class: KS3 Programming Workbook INTRODUCTION TO BB4W BBC BASIC for Windows Name: Class: Resource created by Lin White www.coinlea.co.uk This resource may be photocopied for educational purposes Introducing BBC

More information

Chapter Overview. More Flow of Control. Flow Of Control. Using Boolean Expressions. Using Boolean Expressions. Evaluating Boolean Expressions

Chapter Overview. More Flow of Control. Flow Of Control. Using Boolean Expressions. Using Boolean Expressions. Evaluating Boolean Expressions Chapter 3 More Flow of Control Overview 3.1 Using Boolean Expressions 3.2 Multiway Branches 3.3 More about C++ Loop Statements 3.4 Designing Loops Copyright 2011 Pearson Addison-Wesley. All rights reserved.

More information

CS 302: INTRODUCTION TO PROGRAMMING. Lectures 7&8

CS 302: INTRODUCTION TO PROGRAMMING. Lectures 7&8 CS 302: INTRODUCTION TO PROGRAMMING Lectures 7&8 Hopefully the Programming Assignment #1 released by tomorrow REVIEW The switch statement is an alternative way of writing what? How do you end a case in

More information

CS61A Notes Week 6: Scheme1, Data Directed Programming You Are Scheme and don t let anyone tell you otherwise

CS61A Notes Week 6: Scheme1, Data Directed Programming You Are Scheme and don t let anyone tell you otherwise CS61A Notes Week 6: Scheme1, Data Directed Programming You Are Scheme and don t let anyone tell you otherwise If you re not already crazy about Scheme (and I m sure you are), then here s something to get

More information

Civil Engineering Computation

Civil Engineering Computation Civil Engineering Computation First Steps in VBA Homework Evaluation 2 1 Homework Evaluation 3 Based on this rubric, you may resubmit Homework 1 and Homework 2 (along with today s homework) by next Monday

More information

Introduction, Notepad++, File Structure, 9 Tags, Hyperlinks 1

Introduction, Notepad++, File Structure, 9 Tags, Hyperlinks 1 Introduction, Notepad++, File Structure, 9 Tags, Hyperlinks 1 Introduction to HTML HTML, which stands for Hypertext Markup Language, is the standard markup language used to create web pages. HTML consists

More information

Adobe Business Catalyst

Adobe Business Catalyst Adobe Business Catalyst Adobe Business Catalyst is similar to the Content Management Systems we have been using, but is a paid solution (rather than open source and free like Joomla, WordPress, and Drupal

More information

Getting started with social media and comping

Getting started with social media and comping Getting started with social media and comping Promotors are taking a leap further into the digital age, and we are finding that more and more competitions are migrating to Facebook and Twitter. If you

More information

(Python) Chapter 3: Repetition

(Python) Chapter 3: Repetition (Python) Chapter 3: Repetition 3.1 while loop Motivation Using our current set of tools, repeating a simple statement many times is tedious. The only item we can currently repeat easily is printing the

More information

What is XHTML? XHTML is the language used to create and organize a web page:

What is XHTML? XHTML is the language used to create and organize a web page: XHTML Basics What is XHTML? XHTML is the language used to create and organize a web page: XHTML is newer than, but built upon, the original HTML (HyperText Markup Language) platform. XHTML has stricter

More information

PYTHON YEAR 10 RESOURCE. Practical 01: Printing to the Shell KS3. Integrated Development Environment

PYTHON YEAR 10 RESOURCE. Practical 01: Printing to the Shell KS3. Integrated Development Environment Practical 01: Printing to the Shell To program in Python you need the latest version of Python, which is freely available at www.python.org. Your school will have this installed on the computers for you,

More information

Dynamism and Detection

Dynamism and Detection 1 Dynamism and Detection c h a p t e r ch01 Page 1 Wednesday, June 23, 1999 2:52 PM IN THIS CHAPTER Project I: Generating Platform-Specific Content Project II: Printing Copyright Information and Last-Modified

More information

CpSc 1011 Lab 5 Conditional Statements, Loops, ASCII code, and Redirecting Input Characters and Hurricanes

CpSc 1011 Lab 5 Conditional Statements, Loops, ASCII code, and Redirecting Input Characters and Hurricanes CpSc 1011 Lab 5 Conditional Statements, Loops, ASCII code, and Redirecting Input Characters and Hurricanes Overview For this lab, you will use: one or more of the conditional statements explained below

More information

Mobile Computing Professor Pushpedra Singh Indraprasth Institute of Information Technology Delhi Andriod Development Lecture 09

Mobile Computing Professor Pushpedra Singh Indraprasth Institute of Information Technology Delhi Andriod Development Lecture 09 Mobile Computing Professor Pushpedra Singh Indraprasth Institute of Information Technology Delhi Andriod Development Lecture 09 Hello, today we will create another application called a math quiz. This

More information