Back
Close

Circles and equations.

Statement

 Goal

Pete is in a math exam. He needs your help! He gets an equation each time in the form of
x^2 + y^2 = z

This equation always produces a circle centered on (0,0).

He needs to figure out what x and y are when the angle is a.
a is measured in degrees counterclockwise from the x-axis.

Write a program that when taking the inputs z and a, produces the output
(x, y)
, formatted like this with comma, parentheses and space. Round x and y to one decimal place.

Hint: If you are using cos and sin and getting wrong answers, you might have to convert to radians using angleInRadians = angleInDegrees * ( PI / 180.)
Input
Line 1: Integer z the radius of the circle squared.
Line 2: Integer a - the angle in degrees
Output
One line: The coordinates of the point upon the circles circumference at angle = a in the format
(x, y)
, rounded to the nearest 1d.p.
Constraints
0 <= a < 360
Example
Input
25
45
Output
(3.5, 3.5)

Tags
MathematicsTrigonometry

Difficulty
Medium

Test cases
x^2 + y^2 = 25 and x = y>0 Test
Input
25 45
Output
(3.5, 3.5)

x^2 + y^2 = 16 and x = y>0 Validator
Input
16 45
Output
(2.8, 2.8)

Careful with negative zeroes Test
Input
36 90
Output
(0, 6)

Square? Validator
Input
49 90
Output
(0, 7)

Floating Test
Input
17 190
Output
(-4.1, -0.7)

Doubling Validator
Input
34 214
Output
(-4.8, -3.3)

Full circle Test
Input
36 0
Output
(6, 0)

Almost full circle Validator
Input
36 359
Output
(6, -0.1)

Solution language

Solution

Stub generator input