Write a program that prompts the user for a bearing from 0 to 359 and prints the corresponding letter of the compass point nearest to the bearing. Bearings exactly halfway between two compass points should produce either N or S (never E or W). For example: Input of 73 is between N and E, but is closer
Thank you very much!!
Would I also be able to use a nested if statement in dr java to create this program?
Something like this could be the algorithm ``` input bearing # integer in [0 .. 359] case bearing in [46, 124] then print 'E' case bearing in [125, 225] then print 'S' case bearing in [226, 314] then print 'W' else print 'N' ``` You have to write it in the program language sorry, the editor of open study is a little buggy, had to type it again several times
but you can doe ``` if bearint in... print ... else if bearing .... print ... else if bearing ... pirnt ... else print .... ``` Is that what you mean?
yes Thanks again! :)
Join our real-time social learning platform and learn together with your friends!