Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

image text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

9th Edition

0135188148, 978-0135188149, 9781642087611

More Books

Students also viewed these Databases questions

Question

7. What are the main provisions of the FMLA?pg 87

Answered: 1 week ago

Question

2. Compare the sales and service departments at Auto World.

Answered: 1 week ago