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
Alja [10]
3 years ago
14

g Create a package named lab7 (no spaces, ALL in lowercase) where you will place your lab files. Write a class FilterWith with a

method called filterRange that accepts an ArrayList of integers and two integer values min and max as parameters and removes all elements whose values are in the range min through max (inclusive). For example, if a variable called list stores the values [4, 7, 9, 2, 7, 7, 5, 3, 5, 1, 7, 8, 6, 7], the call of filterRange(list, 5, 7); should remove all values between 5 and 7, changing the list to store [4, 9, 2, 3, 1, 8]. If no elements in range min-max are found in the list, or if the list is initially empty, the list's contents are unchanged. Create an application that creates an object of FilterWith and invokes the filterRange method and show the results
Computers and Technology
1 answer:
sweet [91]3 years ago
3 0

Answer:

See explaination

Explanation:

import java.util.ArrayList;

import java.util.Scanner;

public class ListFilter

{

public static void filterRange(ArrayList<Integer> list,int min, int max)

{

ArrayList<Integer> listNew=new ArrayList<Integer>();

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

{

if(list.get(i)>=min && list.get(i)<=max) //Checking if element is between min and max

{

listNew.add(list.get(i));

}

}

list.removeAll(listNew); //removing all elements from list.

}

public static void main(String[] args)

{

ArrayList<Integer> list=new ArrayList<Integer>();

list.add(4);

list.add(7);

list.add(9);

list.add(2);

list.add(7);

list.add(7);

list.add(5);

list.add(3);

list.add(5);

list.add(1);

list.add(7);

list.add(8);

list.add(6);

list.add(7);

Scanner sc=new Scanner(System.in);

System.out.println("Enter min : ");

int min=sc.nextInt();

System.out.println("Enter Max : ");

int max= sc.nextInt();

filterRange(list, min, max);

//Displaying new List

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

{

System.out.print(list.get(i)+" ");

}

}

}

You might be interested in
a document contains a list of items that appear in no particular order. what is the best way to format the list
krok68 [10]

Answer:

bulleted list

Explanation:

8 0
3 years ago
3 component of a computer
madam [21]

Answer:

Hardware

software

Humanware

6 0
4 years ago
Which of the following is a step in paraphrasing?
Inga [223]

to review the most important supporting points from the original information

7 0
3 years ago
Read 2 more answers
The "A" in the CIA triad stands for "authenticity". True False
mihalych1998 [28]

Answer: False, the "A" in the CIA triad stands for <em>availability</em><em>.</em>

The CIA triad also know as the Confidentiality, integrity and availability triad, is known as a model which is designed in order to implement and enforce policies in regards to information security. This model is also referred as the availability, integrity and confidentiality model i.e AIC triad. This is done in order to avoid confusion with Central Intelligence Agency i.e. CIA.

8 0
3 years ago
What is this <br>name which console it is ​
ZanzabumX [31]

Answer:

ps3

Explanation:

becaus with is and I'm right

6 0
3 years ago
Read 2 more answers
Other questions:
  • What is a benifit of having a client/server network?
    6·1 answer
  • Answer the following questions which are based on the study "Patients' Engagement with Sweet Talk." Submit your answers to the e
    9·1 answer
  • What should you do before cleaning the top of a storage battery and rinsing it with fresh water?
    12·1 answer
  • 14<br> Select the correct answer.<br> Which activity is a marketing technique?
    9·1 answer
  • Select the correct answer.
    6·1 answer
  • Sort short_names in reverse alphabetic order.
    11·1 answer
  • Do you have to make a account of Windows 10?
    12·1 answer
  • Which of the following statements tests if users walked 10,000 or more steps and ate fewer than 25 grams of sugar?
    9·1 answer
  • Why should we not underestimate the widespread of mass media?
    13·1 answer
  • When defining a system
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!