Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 18 Online
OpenStudy (anonymous):

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

OpenStudy (anonymous):

Thank you very much!!

OpenStudy (anonymous):

Would I also be able to use a nested if statement in dr java to create this program?

OpenStudy (anonymous):

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

OpenStudy (anonymous):

but you can doe ``` if bearint in... print ... else if bearing .... print ... else if bearing ... pirnt ... else print .... ``` Is that what you mean?

OpenStudy (anonymous):

yes Thanks again! :)

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!