You will write a program that calculates the principal angle given any co-terminal angle. The principal angle is any angle between 0° inclusive and 360° exclusive, i.e. 0° ≤ θ < 360°. A co-terminal angle can be any angle, possibly negative or larger than 360°, that share the same position as the principal angle.
In general, in order to find the principal angle, you need to either keep adding or keep subtracting the co-terminal angle by 360° until the angle is between 0° and 360°.
Examples:
Co-Terminal Angle | Principal Angle | Reason | |
-30° | 330° | -30° + 360° | one cycle forward |
400° | 40° | 400° – 360° | one cycle back |
800° | 80° | 800° – 360° = 440° 440° – 360° = 80° |
two cycles back |
360° | 0° | 360° – 360° | one cycle back |
100° | 100° | no movement |
Beyond these stated test cases, you need to create you own test cases. The teacher will run through a battery of eight test cases (including some from above) to test your program.
Evaluation: 10 marks
- Test Cases (5 marks)
- Program Code–must use loops (3 marks)
- Flow Chart (2 marks)