Lecture 3 - Raptor Selections
Lecture 3 - Raptor Selections
http://www.bbc.co.uk/education/guides/z3bq7ty/revision/3
INTRODUCTION TO RAPTOR
WHAT’S RAPTOR?
Pause
Stop
Speed of running
RAPTOR STATEMENTS/SYMBOLS
Start
Start
Miles ← 100
X←Y
Distance ← Mile * 5
End
End
Start
Miles ← 100
End
OTHER SYMBOLS
ASSIGNMENT OUTPUT
INPUT STATEMENT STATEMENT STATEMENT
/SYMBOL /SYMBOL /SYMBOL
EXERCISE 1
Prompt the user for two numbers. Use variables called N1 and N2.
Output the multiplication of these two numbers.
Constraint: you should have only two variable in your flowchart:
N1 and N2!
EXERCISE 2
Write an algorithm that takes from the user two numbers, N1 and
N2, swaps the values of these two variables, and outputs them to
the user.
Example: N1=2, N2=10
Statement 1
Decision
Statement 2a Statement 2b
Statement 3
RELATIONAL AND LOGICAL
OPERATORS
Operation Description Example
= "is equal to" 3 = 4 is No(false)
!= "is not equal to" 3 != 4 is Yes(true)
/= 3 /= 4 is Yes(true)
< "is less than" 3 < 4 is Yes(true)
<= "is less than or equal to" 3 <= 4 is Yes(true)
> "is greater than" 3 > 4 is No(false)
>= "is greater than or equal to" 3 >= 4 is No(false)
and Yes(true) if both are Yes (3 < 4) and (10 < 20)
is Yes(true)
or Yes(true) if either are Yes (3 < 4) or (10 > 20)
is Yes(true)
xor Yes(true) if the "yes/no" values Yes xor No
are not equal is Yes(true)
not Invert the logic of the value not (3 < 4)
Yes if No; No if Yes is No(false)
http://www.bbc.co.uk/education/guides/z3bq7ty/revision/3
NESTED SELECTION…
EXERCISE 1
Write an algorithm that takes the GPA of a student and displays whether
this student will be in the President or Dean lists or didn’t make it any of
them.
Recall:
EXERCISE 2
Write an algorithm that takes the GPA of a student and give the letter
grade.
94 – 100 A 77 – 79 C+ 60 – 62 D-
90 – 93 A- 73 – 76 C < 60 F
87 – 89 B+ 70 – 72 C-
83 – 86 B 67 – 69 D+
80 – 82 B- 63 – 66 D
EXERCISE 3
Write an algorithm, using flowcharts, that does the following:
o It will ask the user to choose for which shape they want to compute the
area:
-If the user chooses the circle, it will ask the user for radius
The area of circle is: PI*radius²
- If the user chooses the rectangle, it will ask the user for the height and the
length of the rectangle
The area of the rectangle is: height*length
- If the user chooses the triangle, It will ask the user for the base and height
The area of the circle is: 0.5*height*base
o Your program should print the appropriate area with accompanying text.