You are on page 1of 2

Weekly Coding #1 – Arrays

Problem: Write a program that will check an array for 4 consecutive numbers. Read in the data from the
user. Use the following method header:

public static boolean isConsecutive(int[] values)

- You can assume the array will contain only integer values
- Consecutive numbers occur one after another in incremental values (Example: 13,14,15,16 are
consecutive numbers but 13,15,14,16 are not
- The program should return true if any 4 consecutive numbers are found:
o -2, -1, 0, 1 count (can go from negative  positive)
o Numbers must be in ascending order
o You cannot sort the array

Sample Input:

You might also like