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
David plays racing games on his way to work. He uses the analog stick to navigate his vehicle through other artificial intellige
Sphinxa [80]

Answer: David is most likely playing on Handheld.

Explanation: You can infer that he is playing on a handheld due to the fact that he is playing this game on his way to work, and the fact that he is controlling the game using an analog stick. Because of this, you can assume that what he is playing on needs to be portable, making it likely he is using a handheld.

7 0
3 years ago
Read 2 more answers
Why is there so much stuff popping up on my computer task manager
Morgarella [4.7K]

Answer:

Honestly there could be a number of reasons

Explanation:

could be that you have a virus.

could be unfinished tasks

there's really  lot of reasons this could be happening.

I suggest if its your browser task manager to reset your browser (via browser settings)

If its the system task manager, i suggest trying to restart the computer and go from there.

depending on the root of your problem, it may work, it may not.

Hope this helps :P

7 0
3 years ago
SI TENGO: ¿R = 255, G0 =, B = 0, QUE COLOR OBTENGO?
Ymorist [56]

Answer:

Rojo

Explanation:

No, valores de otros colores 255 para rojo. Esto conducirá al color rojo.

5 0
3 years ago
Google Docs, MS Word, Google Slides, MS PowerPoint, Google Sheets, MS Excel In your opinion which software in each category is e
GREYUIT [131]

Answer:

ms word and ms excel

Explanation:

because thwy are easier to use for begineers

6 0
3 years ago
Read 2 more answers
During the design phase of the systems development life cycle (SDLC), the _____ design is created for a specific platform, such
Firlakuza [10]

Answer:

The answer is "physical design"

Explanation:

This design is the method of translating the specification of circuits into a physical design that explains how cells and roads connect. It is an architecture, that involves the system's internal processes of input and output.

  • This system is created by establishing the design criteria, which determines basically what the applicant system is doing.  
  • It includes the architecture, process architecture and software design of user interfaces.
6 0
3 years ago
Other questions:
  • If the object instance is created in a user program, then the object instance can access both the public and private members of
    9·1 answer
  • The _____ can be used to paste text in any order.
    7·2 answers
  • What has prompted schools to add Internet activities in their academic integrity policies?
    6·2 answers
  • Needed urgently what are short cut keys
    8·2 answers
  • Develop a program so that the output will produce the following :
    8·1 answer
  • What do you call the spreadsheet cell that is in effect and has a heavier black border around it?
    7·2 answers
  • After an attacker has successfully gained remote access to a server with minimal privileges, which of the following is their nex
    15·1 answer
  • 31. Explain what the program does. Write out the output 20 PRINT "Hellooo00000000000, world!" 30 PRINT "I'm learning about comma
    7·1 answer
  • Did you know you can buy a Passport Online?
    12·2 answers
  • An application is getting downloaded, the total size is 52GB. So the speed of the WiFi is like.. 10mb per second, so the questio
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!