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
When would you use conditional formatting on a cell?
Charra [1.4K]
You use conditional formatting on a cell if the numbers are less then zero.
4 0
3 years ago
The list below represents the contents of a computer's main memory. I've left every other byte blank. Assume that the letters at
inysia [295]

Answer:

3) A Single linked list is a sequence of elements in which every element has link to its next element in the sequence.

DATA LINK

DATA stores actual value , LINK stores address of next node

As per information given in question, letters at the even addresses are items in linked list and the odd addresses will be used as links.

Even Address Odd Address

12 (Stores 't') 13 (Used as link)

14 (Stores 'm') 15 (Used as link)

16 (Stores 'a') 17 (Used as link)

18 (Stores 'r') 19 (Used as link)

20 (Stores 's') 21 (Used as link)

Numbers represented by circle are addresses of respective nodes. Here Front or Head has address 16. Which represents the Head Node.

Following image represents the word "smart" with respective nodes and their addressing.

​

Numbers represented by circle are addresses of respective nodes.

The head pointer is: 20

7 0
3 years ago
Linotype is similar to letterpress since both utilize lead type. The difference is that in a linotype, the type is cast into ful
Maru [420]

Answer:

I think it would be.

A-Metal-cast pouring system

<h2>I hope it helps</h2>

8 0
4 years ago
Which language paradigm interacts well with database systems in business environments that use SQL?
HACTEHA [7]
The answer is C, can you mark me brain
6 0
3 years ago
The laser printer in your accounting department is printing faded prints that are getting lighter over time.
algol [13]

Answer:

Option D is correct.

Explanation:

The laser printer well into the finance department of the user publishes blurred images, which are becoming thinner across the time. The paper picking rollers for the fading prints are carried.

  • Option A is not correct because the following option is not related to the faded prints through the laser printer.
  • Option B is not correct because 'fuser' is the Linux command and it is not related to the temperature.
  • Option C is not correct because when the toner is low then it missed the prints.
8 0
4 years ago
Other questions:
  • Create a different version of the program that: Takes a 3-digit number and generates a 6-digit number with the 3-digit number re
    14·1 answer
  • What are some examples of objects by which you can browse in the select browse option
    6·1 answer
  • In the INSERT statement that follows, assume that all of the table and column names are spelled correctly, that none of the colu
    9·1 answer
  • Consider a class called Rocket that has a private instance variable called Engine. You are writing a "getter" for the Engine. Us
    7·1 answer
  • List the six external parts or peripherals of a computer system
    13·1 answer
  • The text size can be found in ?
    9·1 answer
  • The number of bytes in an array is always a multiple of the number of ____ in an array.
    6·1 answer
  • Consider the following high-level recursive procedure: long long int flong long int n, long long int k long long int b b k+2; if
    9·1 answer
  • Cui documents must be reviewed to which procedures before destruction?
    13·1 answer
  • USE PYTHON TURTLE GRAPHICS
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!