Question: import java.util.Random; import java.util.Scanner; public class Compass { // TODO - write your code below this comment. // You will need to write two methods:
import java.util.Random; import java.util.Scanner; public class Compass { // TODO - write your code below this comment. // You will need to write two methods: // // 1.) A method named numberToDirection, which // takes an int and returns a String representing // either a direction, or the string // "Out of range: " + x // ...where x is the input int // // 2.) A method named randomDirection, which // takes a long and returns a String. // The long should be used as a seed value with // which to generate a random number between // 0-7, inclusive. This random number should // then be used as a parameter to a call to // numberToDirection. randomDirection should // return the result of the call to // numberToDirection. // To be clear, randomDirection MUST CALL // numberToDirection! // DO NOT MODIFY main! public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter seed: "); long seed = input.nextLong(); System.out.println("Random direction: " + randomDirection(seed)); } }
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
