Draw different types of angles

Challenge Level: Growing experience

Learning outcomes

Students will be able to:

Requirement:

Write a program that asks the user to enter an angle between 0 and 360 (not including 0 and 360) and displays a message saying if the angle is an acute, right, obtuse, straight or a reflex angle. It then draws two lines of length 100 steps, starting from x:0, y:0, with the given angle between them.

Testing examples:

Your program should display the outputs shown in this table for the given inputs provided:

Input Output
0 The angle you entered is an acute angle.
45 The angle you entered is an acute angle.
90 The angle you entered is a right angle.
110 The angle you entered is an obtuse angle.
180 The angle you entered is a straight angle.
240 The angle you entered is a reflex angle.

Languages

Scratch

What it should look like

Click on the green flag to see the expected output of your program.

Recommended blocks for solution 1
when green flag clicked
clear

set pen size to (3)

pen down

pen up
go to x: (0) y: (0)

point in direction (90 v)

move (100) steps

turn ccw ((180) - (angle)) degrees

move (100) steps
say [The angle you entered is an acute angle.] for (3) secs

say [The angle you entered is a right angle.] for (3) secs

say [The angle you entered is an obtuse angle.] for (3) secs

say [The angle you entered is a straight angle.] for (3) secs

say [The angle you entered is a reflex angle.] for (3) secs
ask [Enter an angle between 0 and 360 (not including 0 and 360):] and wait

set [angle v] to (answer)
if <<(angle) > [0]> and <(angle) < [90]>> then
end

if <(angle) = [90]> then
end

if <<(angle) > [90]> and <(angle) < [180]>> then
end

if <(angle) = [180]> then
end

if <(angle) > [180]> then
end
Recommended blocks for solution 2
when green flag clicked
clear

set pen size to (3)

pen down

pen up
go to x: (0) y: (0)

point in direction (90 v)

move (100) steps

turn ccw ((180) - (angle)) degrees

move (100) steps
ask [Enter an angle between 0 and 360 (not including 0 and 360):] and wait

set [angle v] to (answer)
say [The angle you entered is an acute angle.] for (3) secs

say [The angle you entered is a right angle.] for (3) secs

say [The angle you entered is an obtuse angle.] for (3) secs

say [The angle you entered is a straight angle.] for (3) secs

say [The angle you entered is a reflex angle.] for (3) secs
if <(angle) < [90]> then
else
end

if <(angle) < [180]> then
else
end

if <(angle) = [90]> then
else
end

if <(angle) = [180]> then
else
end
Hints

Description of different angles:

  • An acute angle is an angle between 0 and 90 degrees (not including 90).
  • A right angle is a 90 degrees angle.
  • Obtuse angle is an angle between 90 and 180 degree (not including 90 and 180).
  • A straight angle is a 180 degrees angle.
  • A reflex angle is an angle greater than 180 degrees.

There are different ways to program checking the range using the if()/else blocks. Below are hints for two different ways you may program this:

  • Use a series of if() blocks sequentially checking for the ranges in each if() block. If you need to check a range between two values you can use the <> and <> operator in the condition for your if() block (the AND operator reports true if both conditions are true).

  • Use nested if() or if()/else blocks, which are if()/else blocks inside another set of if()/else blocks (i.e. a nested conditional statement is a conditional statement where the if() and/or else contains another conditional statement). For example:

    if <[angle] < [180]> then if <[angle] < [90]> then acute angle :: custom else if <[angle] = [90]> then right angle :: custom else obtuse angle :: custom end end else if <[angle] = [180]> then straight angle :: custom else reflex angle :: custom end end

Show Scratch solution