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
What type of software can you run to help fix computer problems?
GarryVolchara [31]

Answer:

IOBit Driver Booster.

Explanation:

3 0
3 years ago
Read 2 more answers
What is an example of a boolean operator?
Alona [7]
Boolean operators are like AND,or,not,and not .
they are <span>used as conjunctions to combine or exclude keywords in a search, resulting in more focused and productive results.</span>
3 0
3 years ago
You have an interface on a router with the ip address in the class c network subnet of 192.168.192.10/29. how many total host ad
Gemiola [76]
If 29 bits of the 32 available addressing bits are used for the subnet, then only 3 bits giving 2^3=8 combinations remain for the host addresses. 

In reality, the all zeros and all ones addresses are reserved. So, 8 addresses can exist, but 6 of those are available.

The way the question is formulated it seems the answer 8 is what they're after.
8 0
3 years ago
Can Sombody please help me with this question, I'm struggling!
hjlf

Answer:

umm let me check if my answer is right

Explanation:

3 0
3 years ago
If you delete selected cells using the Delete key on your keyboard, only the _______ of the cells is removed. formatting content
kap26 [50]
If you delete selected cells using the Delete key on your keyboard, only the _______ of the cells is removed.
Content
8 0
3 years ago
Read 2 more answers
Other questions:
  • What is a technology that exists inside another device called
    11·1 answer
  • Electrical pressure is also called
    5·2 answers
  • HURRYYY A friend of yours has E-mailed their English paper to you so that you can proofread it. Explain the tools you would use
    15·1 answer
  • For your biology class, you have taken a number of measurements for a plant growth experiment. You wish to create a chart that s
    10·1 answer
  • I have $80 and I want a smartphone that you can call for free what should I get
    14·2 answers
  • A. True
    11·1 answer
  • Whitch event describes a festival in rio, brazil that includes a samba parade and eccentric outfits?
    13·1 answer
  • the computer that communicate with each other are called ______please ask the answer in 15 minutes after 1 p.m. ​
    9·1 answer
  • Describe how computer are used in ticket counter?​
    10·1 answer
  • A(an)_______is built-in preset calculation. <br>formula <br> function <br>equation <br>AutoSum​
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!