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]
2 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]2 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
Explain the working system of computer systems with examples​
geniusboy [140]

,I don't know you all about computer

8 0
2 years ago
In what country was the English royal family and nobility living before the Restoration?
krek1111 [17]

im not sure to be exact , but i think its england. i have done an assignment in the past and that was the awnser.....hope i help                      

4 0
3 years ago
Read the statement and justify your answer. “ICT is important for every field.”
Alja [10]

Explanation:

ICT permeates all aspects of life, providing newer, better, and quicker ways for people to interact, network, seek help, gain access to information, and learn. Besides its presence everywhere, Information and Communication Technology has an immense economic significance.

4 0
3 years ago
PLATO
storchak [24]

Answer: here is the answer ☀️keep on shining☀️

Explanation:

5 0
3 years ago
Easy Bib and Cite This For Me are examples of online
motikmotik
The answer is:  [A]:  "bibliographic generators" .
____________________________________________________
5 0
3 years ago
Other questions:
  • Mara's presentation included essential information about the company's new safety procedures. She wanted to make
    13·2 answers
  • How to move files and folders from desktop in w10?
    13·1 answer
  • Describe the Software Development Life Cycle. Describe for each phase of the SDLC how it can be used to create software for an E
    14·1 answer
  • Suppose you use Batch Gradient Descent to train a neural network and you plot the training error at every epoch. If you notice t
    7·1 answer
  • 5.
    6·1 answer
  • Head-mounted displays often use organic light emitting diode,or technology.
    15·1 answer
  • Write a program that takes in a line of text as input, and outputs that line of text in reverse. The program repeats, ending whe
    5·2 answers
  • Text that is heavier or darker than other text in the document is considered _____.
    9·2 answers
  • Given a constant named size with a value of 5, which statement can you use to define and initialize an array of doubles named ga
    12·1 answer
  • Use the drop-down menus to complete the statements about changing mail options in Outlook.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!