1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
zhuklara [117]
3 years ago
6

Write a method named countInRange that accepts three parameters: an ArrayList of integers, a minimum and maximum integer, and re

turns the number of elements in the list within that range inclusive. For example, if the list v contains {28, 1, 17, 4, 41, 9, 59, 8, 31, 30, 25}, the call of countInRange(v, 10, 30) should return 4. If the list is empty, return 0. Do not modify the list that is passed in.
Computers and Technology
1 answer:
marissa [1.9K]3 years ago
6 0

Answer:

In Java:

The method is as follows:

public static int countInRange (ArrayList<Integer> MyList, int min, int max) {  

       int count = 0;

       for (int i = 0; i < MyList.size(); i++)  {

           if(MyList.get(i)>=min && MyList.get(i)<=max){

               count++;

           }  

       }

       return count;

 }

Explanation:

This defines the method

public static int countInRange (ArrayList<Integer> MyList, int min, int max) {

This declares and initializes count to 0  

       int count = 0;

This iterates through the ArrayList

       for (int i = 0; i < MyList.size(); i++)  {

This checks if current ArrayList element is between min and max (inclusive)

           if(MyList.get(i)>=min && MyList.get(i)<=max){

If yes, increase count by 1

               count++;

           }  

       }

This returns count

       return count;

 }

To call the method from main, use:

countInRange(v,m,n)

<em>Where v is the name of the ArrayList, m and n are the min and max respectively.</em>

You might be interested in
Compare entertainment applications to social media applications.
ladessa [460]
A. both allow user to stay current with the latest information.
4 0
3 years ago
Read 2 more answers
The algorithm ____ is used to find the elements in one range of elements that do not appear in another range of elements.
Musya8 [376]

Answer:

A. set_union

Explanation:

The algorithm set_union is used to find the elements in one range of elements that do not appear in another range of elements.

4 0
3 years ago
UPS or FedEx plays what role in the supply?
nikdorinn [45]

Explanation:

the answer in the image above

8 0
2 years ago
14. The heart of a computer is<br> a CPU<br> b. Memory<br> c. I/O Unit<br> d. Disks
NNADVOKAT [17]

Answer:

CPU

I dont know a whole ton about computers. But I'm confident this is correct. Without the CPU the other options on this list wouldnt work so the CPU would be the "heart".

3 0
3 years ago
Your search google for recipe for tonight dinner is an.example of ?​
Rina8888 [55]

The example is, ethier you need cooking classes or you wish to try something new

Hope the little humor helps

3 0
3 years ago
Read 2 more answers
Other questions:
  • What was the second phone?
    14·1 answer
  • True or false words spelling and grammar check is always %100
    7·2 answers
  • What is daemontools pakage in qmail?
    14·1 answer
  • Given the following business scenario, create a Crow's Foot ERD using a specialization hierarchy if appropriate. Granite Sales C
    12·1 answer
  • A professor is working with five teams in his marketing research class. He decides to experiment with path-goal theory in helpin
    11·1 answer
  • Different video files and ______ can cause compatibility issues to arise between computer systems.
    8·1 answer
  • Thomas drew a rectangle with an area of 6 square cm what is the greatest possible perimeter of this rectangle
    5·1 answer
  • A(n) __ is a list of main points and sub-points of a topic to include in a presentation
    14·2 answers
  • Set methods are also commonly called _____ methods, and get methods are also commonly called _____ methods.
    6·1 answer
  • ______________________ can run on a workstation or server and is at the heart of all business applications.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!