Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Lab Description: Given a provided array, determine how many groups of a specified size exist. For the array [i,1,1,2,2,2,3,3,3,4,5, 6, 7], there are 7 groups
Lab Description: Given a provided array, determine how many groups of a specified size exist. For the array [i,1,1,2,2,2,3,3,3,4,5, 6, 7], there are 7 groups with at least one, 3 groups with at least 2, and 3 groups with at least 3. A group is a series of same values. 1 1 1 is a group of 3, but it also is a group of 1 and 2. To count as a group, all values must be the same. 1 1 1 is a group of 3 because there are 3 1s in a row Sample Data: 3 33 33 94445 5 5 5 6 677788B 8 8 888 1 2 3 456789 1 1 1 211 333 3 33 333 3 4 445 444 6 Files Needed ArrayStats.java ArrayStatsRunner.java Sample Output [3, 3, 3, 3, 3, 9, 4, 4, 4, 5, 5, 5, 5, 6, 6, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8] size 1 count7 size 2 count--6 size 3 count-5 size 4 count3 size 5 count2 size 6 count1 [1, 2, 3, 4, 5, 6, 7, 8, 9] size 1 count-9 size 2 count-0 size 3 count-0 size 4 count0 size 1 count8 size 2 count-5 size 6 count1 size B count1 import static java.lang.System.* import java.util.Arrays; import java.util.Scanner; public class ArrayStats /linstance variable //constructor //set method public int getNumGroupsofSize(int size) int cnt-0; return cnt; public String toString() return ""+Arrays.tostring(array) public class ArraystatsRunner public static void main(String args[])
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