Answered step by step
Verified Expert Solution
Question
1 Approved Answer
STARTER CODE: public class PA2b { /** * Error to supply if input is not positive */ public static final String ERR_VALUES = Number of
STARTER CODE:
public class PA2b { | |
/** | |
* Error to supply if input is not positive | |
*/ | |
public static final String ERR_VALUES = "Number of values must be positive."; | |
/** | |
* Returns true if the supplied array has a | |
* sequence of k consecutive values | |
* | |
* @param values input array | |
* @param k sequence length for which to search | |
* @return true if values has a consecutive sequence of at least k | |
*/ | |
public static boolean hasConsecutive(int[] values, int k) { | |
return false; | |
} | |
/** | |
* Returns the length of the longest | |
* consecutive sequence in the supplied | |
* array | |
* | |
* @param values input array | |
* @return length of the longest consecutive value sequence in values | |
*/ | |
public static int maxConsecutive(int[] values) { | |
// Hint: hasConsecutive could | |
// be very useful here | |
return 0; | |
} | |
/** | |
* Inputs an array of numbers | |
* and outputs the longest consecutive | |
* sequence of values | |
* | |
* @param args command-line arguments, ignored | |
*/ | |
public static void main(String[] args) { | |
// Hint: useful methods and constants here | |
// - maxConsecutive | |
// - ERR_VALUES | |
} | |
} |
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