0% found this document useful (0 votes)
1 views1 page

public class ArrayStatsRunner {

The document is a Java program that prompts the user to input the size and elements of an array, as well as a group size to count. It then creates an instance of the ArrayStats class to calculate the number of groups of the specified size within the array. Finally, it outputs the array and the count of groups of the given size.

Uploaded by

gouraiahnaga
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views1 page

public class ArrayStatsRunner {

The document is a Java program that prompts the user to input the size and elements of an array, as well as a group size to count. It then creates an instance of the ArrayStats class to calculate the number of groups of the specified size within the array. Finally, it outputs the array and the count of groups of the given size.

Uploaded by

gouraiahnaga
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

public class ArrayStatsRunner {

public static void main(String[] args) {


Scanner scanner = new Scanner(System.in);

// Accept user input for the array size


System.out.print("Enter the size of the array: ");
int n = scanner.nextInt();

// Accept user input for the array elements


int[] arr = new int[n];
System.out.println("Enter the array elements: ");
for (int i = 0; i < n; i++) {
arr[i] = scanner.nextInt();
}

// Accept user input for the group size to count


System.out.print("Enter the group size to count: ");
int size = scanner.nextInt();

// Create an ArrayStats object and calculate the number of groups of the


given size
ArrayStats stats = new ArrayStats(arr);
int result = stats.getNumGroupsOfSize(size);

// Output the results


System.out.println("Array: " + stats.toString());
System.out.println("Number of groups of size " + size + ": " + result);

scanner.close();
}
}

You might also like