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). The program should loop until the user enters -1, all other values that are not 0 – 359 should produce an error message.
@Ultrilliam
@extrinix are coding?
It should be something roughly similar to this, given from OpenStudy's original post on it. This will have to be transformed into Java though for your purposes. input bearing # integer in [0 .. 359] case bearing in [315, 45] then print 'N' 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 'ERROR' this is what the code in non java form looks like... but ill convert it to java form
how do you convert it into java
Are you still here Extrinix
^
java
You can use the java class Scanner to read in input from the user. Walkthrough here: https://careerkarma.com/blog/java-input/#:~:text=The%20Scanner%20class%20is%20used%20to%20read%20Java,so%20it%20can%20be%20stored%20or%20otherwise%20manipulated. In order to check the cases as Extrinix described, you'd probably want switch-case statements. Walkthrough here: https://docs.oracle.com/javase/tutorial/java/nutsandbolts/switch.html
Join our real-time social learning platform and learn together with your friends!