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
Give an example of a language L such that |L|=5 and |L^2|=16.
Basile [38]

Answer:

He can define pas follows: Let P be defined on the set of languages accepted by some Turing machine M. Let it be True if 10 ] is 5 and False otherwise.  

Explanation:

The domain of P is the SD languages since it is those languages that are accepted by some Turing machine H. P is nontrivial since P({ a, aa, aaa, aaaa, aaaaa, aaaaaa, b, bb, bbb, bbbb, bbbbb, bbbbbb } ) is True and P ( 5 ) is False.  

Thus {< M> is a Turing machine and I L I - 5 and  I L I - 16 }

7 0
3 years ago
Why should you stay out of the open space to the right of a semi tractor trailer?
dimulka [17.4K]
The right side to a semi tractor trailer is their huge blind side, meaning the driver can't see you, and may merge lanes with you, thus crashing into you.
5 0
3 years ago
Read 2 more answers
Suppose that a 64MB system memory is built from 64 1MB RAM chips. How many address lines are needed to select one of the memory
alexdok [17]

Answer:

6 address lines

Explanation:

The computation of the number of address lines needed is shown below:

Given that

Total memory = 64MB

= 2^6MB

=2^{26} bytes

Also we know that in 1MB RAM the number of chips is 6

So, the number of address lines is 2^{26} address i..e 26 address lines

And, the size of one chip is equivalent to 1 MB i.e. 2^{20} bytes

For a single 1MB chips of RAM, the number of address lines is

\frac{2^{26}}{2^{20}} \\\\= 2^6 address

Therefore 6 address lines needed

5 0
3 years ago
What is the name of the variable in this code?
nata0808 [166]

Answer:

fav_color

Explanation:

4 0
2 years ago
Read 2 more answers
Write a C++ program that produces a simple personalized adventure game called Lost Fortune about a band of explorers that finds
Natasha2012 [34]

Answer:

Detailed answer is given :

8 0
2 years ago
Other questions:
  • What is the final step used when designing an algorithm?
    14·1 answer
  • https://brainly.com/app/ask?entry=top&amp;q=What+did+you+learn+during+this+course+that+reinforces+your+belief+in+your+technology
    5·1 answer
  • Which is the correct formula to add the values in cells A1 and B1? A. SUM(A1+B1) B. =SUM(A1+B1) C. =SUMA1+B1 D. A1+B1
    9·2 answers
  • Is ubisoft still making assassins creeds on xbox 360
    8·2 answers
  • PLEASE HELP!!! THIS IS WORTH A TEST GRADE!!!
    13·1 answer
  • Which is NOT an example of a "Serious Game"?
    9·1 answer
  • What is an orthochromatic film?
    12·1 answer
  • In the digital age we have less time to absorb and make sense of new information
    12·2 answers
  • The complete process for learning through repetition is to read, write, say, rest and revisit the information. Please select the
    12·2 answers
  • I will give brainliest to the best answer. what is a good screen recorder
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!