Find Us On: Facebook Twitter Rss Feed Blog
Need To Register? Sign Up Login

Simple Java program 1

BunkerHillBroad
BunkerHillBroad 


use file CountInRange.java Define a static Java method named countInRange that accepts as parameters: an array of integers, a minimum value, and a maximum value. The method should return the count of how many elements from the array fall between the minimum and maximum values (inclusive). For example, in the array {14, 1, 7, 22, 17, 36, 7, -43, 5} there are 5 elements whose values fall between 4 and 17. Note: if duplicate values exist in the array, they should get counted anyway. Write a main method that convincingly demonstrates your method in action on a variety of arrays. Please note that the array being passed as argument to countInRange is not sorted and you may not sort it! Attachments
Tags Clarifications

Answers

CountInRange - Solution

mariobeka
mariobeka 



Below the solution java file for the given task. Attachments
CountInRange.java (1 K) Download Preview
maximum range. */ static public int countInRange(int[] array, int min, int max) { int count = 0; for (int num : array) { if (num

Screenshots
Purchase Answer

Simple Java Program 1 (Count In Range)

uetian_cute
uetian_cute 



The solution contains the implemented method.
And a main method that allows you to test it for any array.
Attachments
CountInRange.zip (1 K) Download
Preview
static void main ( String[] args ) { Scanner in = new Scanner(System.in); System.out.print("Enter the size of the int array: "); int size = in.nextInt(); int[] arr = new int[size]; for ( int i = 0; i < arr.length; i++ ) {

Screenshots
Purchase Answer