Question: PLEASE CODE IN C++ ONLY! Ionas is developing the JUxtaPhone and is tasked with t .is Rational, animating the compass needle. The API is simple:

PLEASE CODE IN C++ ONLY!  PLEASE CODE IN C++ ONLY! Ionas is developing the JUxtaPhone and
is tasked with t .is Rational, animating the compass needle. The API

Ionas is developing the JUxtaPhone and is tasked with t .is Rational, animating the compass needle. The API is simple: the compass argo-tm yny.y needle is currently in some direction (between 0 and 359 degrees, with north being 0, east being 90), and is being animated by giving the degrees to spin it. If the needle is hypot (x.Y) r arg.is Rational eturn sart (aro returnsqrta pointing north, and you give the compass an input of 90, it will spin clockwise (positive numbers mean clockwise direction) to stop at east, whereas an input of -45 would spin it counterclockwise to stop at north west. n rotat ing cc-by NCPC 2016 The compass gives the current direction the phone is pointing and Jonas' task is to animate the needle taking the shortest path from the current needle direction to the correct direction. Many ifs, moduli, and even an arctan later, he is still not convinced his minimumDistance function is correct, he calls you on the phone. Input The first line of input contains an integer ni (O SI 359), the current direction of the needle. The second line of input contains an integer n2 (0 S n2 359), the correct direction of the needle Output Output the change in direction that would make the needle spin the shortest distance from n1 to n2 A positive change indicates spinning the needle clockwise, and a negative change indicates spinning the needle counter- clockwise. If the two input numbers are diametrically opposed, the needle should travel clockwise. Le, in this case output 180 rather than 180 Output Output the change in direction that would make the needle spin the shortest distance from n1 to n2. A positive change indicates spinning the needle clockwise, and a negative change indicates spinning the needle counter- clockwise. If the two input numbers are diametrically opposed, the needle should travel clockwise. Le., in this case, output 180 rather than-180. Sample Input 1 Sample Output 1 315 45 90 Sample Input 2 Sample Output 2 188 270 90 Sample Input 3 Sample Output 3 45 270 135

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!