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
Declare a structure with a type name: Car containing:
OLga [1]

Answer:

C++ code is given below

Explanation:

#include <iostream>

#include <cctype>

#include <string.h>

#include <cstring>

#include <sstream>

using namespace std;

struct Car {

public:    

char reportingMark[5];    

int carNumber;

string kind;

bool loaded;

string destination;

};

void input(Car *);

void output(Car *);

int main() {

Car *T = new Car;    

input(T);

output(T);    

delete T;    

return 0;

}

void input(Car *T)

{

string str, s;

cout << " Enter the reporting mark as a 5 or less character uppercase string: ";

cin >> str;

for (int i = 0; i < str.length(); i++)

T->reportingMark[i] = toupper(str[i]);

cout << " Enter the car number: ";

cin >> T->carNumber;

cout << " Enter the kind: ";

cin >> T->kind;

cout << " Enter the loaded status as true or false: ";

cin >> s;    

istringstream(s) >> boolalpha >> T->loaded;    

if (T->loaded == true) {

cout << " Enter the destination: ";

cin.ignore();

getline(cin, T->destination);

}

else

T->destination = "NONE";    

}

void output(Car *T)

{

cout << " Reporting Mark: " << T->reportingMark;

cout << " Car Number: " << T->carNumber;    

cout << " Kind: " << T->kind;

cout << " Loaded Status: " << boolalpha << T->loaded;

cout << " Destination: " << T->destination << " ";

}

7 0
3 years ago
Engineers at Edison Laboratories developed a _____ strip that allowed them to capture sequences of images on film.
maxonik [38]

Answer:

Kinetoscope

Explanation:

4 0
2 years ago
Read 2 more answers
Anyone wanna hop on 1v1.lol<br> party code : usfhb6
hjlf

Answer:

thx for the points

Explanation:

8 0
2 years ago
Read 2 more answers
How do i do this?
Ksivusya [100]

Answer: deezzz mf nuts

Explanation:

5 0
3 years ago
Andrew’s Complete Cameras offers its customers an interactive website to help them choose the best camera for their lifestyle. B
julsineya [31]

Answer:

The correct answer is letter "A": Engage.

Explanation:

Social media has gained importance not only as an informative medium but as a means for marketing. The 4E framework states the four basic characteristics social media advertisement should fulfill. Those components are:

  • Excite.<em> Provide customers attractive offers.</em>
  • Educate.<em> Give consumers information about the product and the offering.</em>
  • Experience.<em> Allow direct or indirect interaction with the good.</em>
  • <u>Engage</u>.<em> Involve customers in activities related to the product that transcend the simple buying of the good.</em>
8 0
3 years ago
Other questions:
  • 1- Design a brute-force algorithm for solving the problem below (provide pseudocode): You have a large container with storage si
    10·1 answer
  • In order for you to make a wireless connection it must first find an availble
    8·1 answer
  • What are the guided and unguided transmission media and what are the differences?
    15·1 answer
  • How do you freeze the total cell so that it doesn't change when copied?
    6·1 answer
  • Percentage-wise, which renewable energy source is used most?
    13·1 answer
  • If you play gta and don't know the song ''Glamorous'' Then what do you even do when you play?
    6·2 answers
  • Create an online order form for a car rental store and include the following items: input text box to enter the number of days i
    14·1 answer
  • Using a tag, set the color to orange for all tags
    13·2 answers
  • ________ is a group meeting-based process for requirements collection. a. Reverse engineering b. Joint application design c. Hum
    9·1 answer
  • I watched an ad but the im button done is no where in sight, has anyone else experienced this recently. it was fine a few days a
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!