INT213Lab3

INT213Lab3 - Lab 3 - INT213 Conditionals This lab will...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Lab 3 - INT213 Conditionals This lab will concentrate on decision making process. It is this type of programming code elements that make computers appear to be intelligent. Without them you would not be able to perform many useful functions. Make sure you understand the concepts of Conditionals. They are vital not only in this course, but in other scripting courses in the CNS/CTY program. Operators Before getting into Conditionals, we need to look at the operators that are available and are required to help us evaluate conditions. These Operators are designed to help create the questions asked in the scripts and also to help provide the True/False answers to the questions. Operator Symbol Examples Equal to = 5 = 5 “john” = “john’ Not equal to <> 1<> 5 “Smith” <> “Jones” Greater than > 10 > 5 “B” > “A” Less than < 5 < 10 “A” < “B” Less than or equal to <= 5 <= 5 4 <= 5 “a” <= “b” Greater than or equal to >= 10 >= 5 10 >= 10 “yes” >= “no” Conditional Statements Basically, Conditionals are those script elements that make decisions. A question is set up and the computer must make a YES/NO decision. No matter how simple or complex the question, the answer will always be YES or NO . A simple question would be “Is 5 greater than 2”. The answer would be YES (True). You will provide the computer with options of performing an action based on the answer. If YES do this and if NO do something else. If…Then ( Single line) Although we can create some very complex IF…Then statements, we will start with something very simple. The basic form of the If…Then conditional is a simple way of deciding between two courses of action. That is, based on the outcome of a True or False question the script will do one of two things. Let’s look at out first example. In your editor create the following file File name: INT213lab3a.asp <% Option Explicit ‘set up variables Dim intweight ‘give variable a value intweight = 101 ‘check if weight is over 100 pounds If intweight > 100 Then Response.write “You are over 100 pounds” %> Save this file to your IIS directory and execute in your browser ( http://127.0.0.1/INT213lab3a.asp ) Comments:
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the simplest form of ‘If’ statement. It is basically testing the question Is the value of intweight greater than 100? If it is then output the response. If not then do nothing. Exercise 1) Using a different Operator , change the script line so that a weight greater than or equal to 100 would be included in the test. Write this line below and test your answer in the script. _______if intweight>=100_____________________________________________ 2) Change the value of intweight to 90 and execute the script again. What was the output? ____________blank page_____________________________________________
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/27/2011 for the course INT 213 taught by Professor Tim during the Fall '10 term at Seneca.

Page1 / 8

INT213Lab3 - Lab 3 - INT213 Conditionals This lab will...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online