PT 1420
Unit 5 Assignment 1
Homework
Short answer
1. Conditionally executed means it is performed only when a certain condition is true.
2. You would use a dual alternative decision structure.
3. You would use a nested decision structure.
4. The AND operator connects two Boolean expressions into one compound expression. Both must be true for the compound expression to be true.
5. The OR operator connects two Boolean expressions into one compound expression. One or both must be true for the compound expression to be true. It doesn’t matter which one.
6. When determining if a number is within a range, the OR operator would be best to use.
7. A flag is a variable that signals when some condition exists in the program.
Algorithm Workbench
1. If variable x > 100 Then
Set variable y = 20
Set variable z = 40 End If
2. If variable a < 10 Then
Set variable b = 0
Set variable c = 1 End if
3. If variable a < 10 Then
Set variable b = 0 Else Set variable b = 99 End If
4. If score < 60 Then
Display “Your grade is F.” Else If score < 70 Then Display “Your grade is D.” Else
If score < 80 Then Display “Your grade is C.” Else If score < 90 Then Display “Your grade is B.” Else Display “Your grade is A.” End If End If End If End If
5. If amount1 > 10
And
If amount2 < 100 Then
If amount1 > amount2 Then Display amount 1
Else
Display amount2
End if
Programming Exercises
1. Declare Integer number
If number variable is set to 1, it displays “ I “
If number variable is set to 2, it displays “ II “
If number variable is set to 3, it displays “ III “
If number variable is set to 4, it displays “ IV “
If number variable is set to 5, it displays “ V “
If number variable is set to 6, it displays “ VI “
If number variable is set to 7, it displays “ VII “
If number variable is set to 8, it displays “ VIII “
If number variable is set to 9, it displays “ IX “
If number variable is set