Skip to main content

Section 5.3 Assessment: Relational Expressions

Subgoals for Writing Selection Statements.

If Statement
  1. Define how many mutually exclusive paths are needed
  2. Order from most restrictive/selective group to least restrictive
  3. Write if statement with Boolean expression
  4. Follow with true bracket including action
  5. Follow with else bracket
  6. Repeat until all groups and actions are accounted for
OR Switch Statement
  1. Determine variable / expression for mutually exclusive ranges
  2. Write switch statement based on variable / expression
  3. Each range is a ‘case’
  4. Include break statements and default case if needed

Subsection 5.3.1 Write Relational Expressions

For each of the following, fill in the blank with the appropriate operator.

Exercises 5.3.2 Exercises

    1.

    Q1: z is odd
    z % 2 1

    2.

    Q2: z is not greater than y’s square root
    z Math.sqrt(y)

    3.

    Q3: y is a multiple of z
    y % z 0

    4.

    Q4: z is not zero
    z 0

    5.

    Q5: z is nonnegative
    z 0

    6.

    Q6: x is even
    x % 2 1
You have attempted of activities on this page.