Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I am trying to find the minimum distance between target and the number correspond to the array, i do get the distance but i do
I am trying to find the minimum distance between target and the number correspond to the array, i do get the distance but i do not know how to get the minimum. programming language is JAVA SE8
public class MinDistance public static int distance(byte target, byte[] numbers) *purpose: determine the minimal distance between any * input : target is the number we are looking for * output : the method returns two instances of target in the numbers array numbers is an array of numbers o) the minimal distance between any two instances of target in the numbers array, if there are at least two instances of target present, or o) -2 if target is not in the numbers array, or o) -1 if target appears only once in the numbers array return -12345 main method can be used for basic test cases. Modify the method to add more test cases. Your main method wi11 NOT be graded. But, be sure it does cause your class to not compile public static void main(String[] args) byte[] N = {5,3,7,2,3,4,4,7,3,-1 , 3 , 4, 7,5), System out.println distance ((byte)5, N)); System out.println distance ((byte) 4, N)); System out.println distance ((byte)7, N)); System out.println distance ((byte)3, N)); System out.println distance ((byte)2, N)); System out.println distance ((byte) 13, N))Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started