  # Week 5 Assignments New

Topics: Equals sign / Pages: 6 (754 words) / Published: Feb 12th, 2015
PT1420 - Unit 5 Homework and Lab Assignment

Unit 5 Assignment 1: Homework
1.) Design an if-then statement that assigns 20 to the variable y and assigns 40 to the variable z if the variable x is greater than 100. (Simple if statement)
If x > 100 then Y=20 Z=40
End if

2.) Design an if-then statement that assigns 0 to the variable b and assigns 1 to the variable c if variable a is less than 10. (Simple if statement)

3.) Design an if-then-else statement that assigns 0 to variable b if variable a is less than 10, otherwise it should assign 99 to variable b. (Alternative if statement) If a < 10 then B = 0 Else B = 99 End f

4.) The symbols >, <, and == are all Relational operators.

5.) The if-then statement is an example of a conditioal structure.

6.) The Selection structure is based on boolean logic.

7.) The if-else statement is know as a dual alternative decision structure.

8.) A nested if statement is used to ask multiple questions before deciding what processing path to take.

True False

*****************************************************************

Unit 5 Labs

1.) Lab 5.1: Evaluating Conditions with Relational Operators.

Critical Review

A relational operator determines whether a specific relationship exists between two values.

Relational operators
Operator
Meaning
Boolean Expression
>
Greater than
X > Y
<
Less than
X < Y
>=
Greater than or equal to
X >= Y
<=
Less than or equal to
X <= Y
=
Equal to
X = Y
!=
Not equal to
X != Y

Step 1: Consider the following values set to variables. myAge = 32 yourAge = 18 myNumber = 81 yourNumber = 17 votingAge = 18 myName = “Katie” yourName = “Bob

Step 2: Based on the values to the variables in Step 1, do the following conditions result in a true or false statement?

2.) Lab 5.2: Evaluating Outputs Resulting from Relational Condition Evaluations.

Step 3: Based on the values to the variables in Step 1 above, what is the expected output resulting