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
Tell me at list 5 farm animals dieases​
Vlad [161]
<h3>Answer : </h3>

<em><u>F</u></em><em><u>a</u></em><em><u>r</u></em><em><u>m</u></em><em><u> </u></em><em><u>C</u></em><em><u>o</u></em><em><u>m</u></em><em><u>m</u></em><em><u>o</u></em><em><u>n</u></em><em><u> </u></em><em><u>D</u></em><em><u>i</u></em><em><u>s</u></em><em><u>e</u></em><em><u>a</u></em><em><u>s</u></em><em><u>e</u></em><em><u>s</u></em><em><u> </u></em><em><u>:</u></em><em><u> </u></em>

<em><u>.</u></em><em><u> </u></em><em><u>General Farm Animal Diseases.</u></em>

<em><u>.</u></em><em><u> </u></em><em><u>Avian Influenza.</u></em>

<em><u>.</u></em><em><u> </u></em><em><u>Bovine Spongiform Encephalopathy (BSE)</u></em>

<em><u>.</u></em><em><u> </u></em><em><u>Foot-and-Mouth Disease.</u></em>

<em><u>.</u></em><em><u> </u></em><em><u>West Nile Virus.</u></em>

Explanation:

<em><u>H</u></em><em><u>o</u></em><em><u>p</u></em><em><u>e</u></em><em><u> </u></em><em><u>i</u></em><em><u>t</u></em><em><u> </u></em><em><u>h</u></em><em><u>e</u></em><em><u>l</u></em><em><u>p</u></em><em><u>s</u></em><em><u> </u></em><em><u>o</u></em><em><u>u</u></em><em><u>t</u></em><em><u> </u></em><em><u>:</u></em><em><u>)</u></em><em><u>)</u></em>

7 0
3 years ago
Read 2 more answers
What office application has animations on the home ribbon?
Eva8 [605]
It's Microsoft office power point presentation.
3 0
3 years ago
Read 2 more answers
An electronic spreadsheet is a type of<br> archive.<br> database.<br> document.<br> periodical.
zhenek [66]

Answer:

The answer is "database"

Explanation:

The spreadsheet is an application program, that is used to organized, analysis, and store data in tabular format. It is also used to import data and provide a database in programming that is used to store data and other option is not correct that can be described as follows:

  • Archive uses VBA that stands for "Visual Basic for Applications", it is used to store data in an archive file, that's why it is not correct.
  • Document is a file that is used to store data, that's why it is not correct.
  • Periodical use graph and bar charts to display data graphically, that's why it is not correct.

7 0
3 years ago
Read 2 more answers
A tornado destroyed many
m_a_m_a [10]

Answer:

D is your answer because I'm an expert

5 0
3 years ago
Read 2 more answers
When saving a file, you must provide a valid file name that adheres to specific rules, referred to as _______________.
Naya [18.7K]

Answer:

a. file-naming conventions

Explanation:

File names need to follow certain criteria and constraints. Examples include:

  • File names must not start with special symbols.
  • File names can consist of letters,digits and special characters such as _.
  • File name can contain an extension after a dot sign.
  • File names must not be duplicates of an existing file.

Such constraints form part of file-naming conventions.

  • file-path represents the complete path to the file in the directory structure.
  • disk partition segments a hard disk into multiple volumes.
  • file-path starts from the root directory and spans one or more subdirectories to the location of the actual file.
6 0
3 years ago
Other questions:
  • Which of the following is an occupation management group? Select the choice that best answers the question.
    15·1 answer
  • Emotional intelligence is a new term to describe personal traits ?
    12·1 answer
  • What adds the element carbon to the environment
    10·2 answers
  • Which type of microscope can only be used to view non-living specimens?
    10·2 answers
  • so i just went to play forge of empires and when i logged on to it all of my progress was gone and i was so far in to it
    15·2 answers
  • Computer software is regarded a bridge between the hardware and software.elaborate the statement outlining types and functions o
    10·1 answer
  • 54 points!!! Cyber security
    14·1 answer
  • How does this happen on brianly???
    5·2 answers
  • What plan can businesses use to protect sensitive data from malicious attacks?
    11·2 answers
  • Which of these can be a problem for people with accessibility issues? Select 4 options.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!