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
mihalych1998 [28]
3 years ago
12

Write a method called findNames that meets the following specs: It takes two arguments: a list of strings, allNames, and a strin

g, wanted Creates and returns a new list containing only the strings from, allNames, that contain the name stored in wanted as a substring. List allNames should remain unmodified: do not delete, or modify the names in it. This should work in a case insensitive manner, but the names in your result list should be exactly as they are in A (i.e. not converted to lower case). We referred to allames and what the method retums as 'lists', but you are free to represent cach one of them however you want: array or ArrayList. No error checking needed. Example behavior: if allNames is: ["Bob Smith", "Elroy Jetson", "Christina Johnson", "Rachael Baker", "Chris Conly"] and wanted is "cHRis" the resulting list, should be: ["christina Johnson", "Chris Conly"] because only those two strings contain "chris"
Computers and Technology
1 answer:
Anna11 [10]3 years ago
8 0

Answer:

public class Solution {

   public static void main(String args[]) {

       String[] allNames = new String[]{"Bob Smith", "Elroy Jetson", "Christina Johnson", "Rachael Baker", "cHRis", "Chris Conly"};

       String searchString = "cHRis";

       

       findNames(allNames, searchString);

   }

   

   public static void findNames(String[] listOfName, String nameToFind){

       ArrayList<String> resultName = new ArrayList<String>();

       

       for(String name : listOfName){

           if (name.toLowerCase().contains(nameToFind.toLowerCase())){

               resultName.add(name);

           }

       }

       

       for(String result : resultName){

           System.out.println(result);

       }

   }

}

Explanation:

The class was created called Solution. The second line define the main function. Inside the main function; we initialized and assign an array called allNames to hold the list of all name. Then a String called searchString was also defined. The searchString is the string to search for in each element of allNames array. The two variables (allNames and searchString) are passed as argument to the findNames method when it is called.

The method findNames is defined and it accept two parameters, an array containing list of names and the name to search for.

Inside the findNames method, we initialized and assigned an ArrayList called resultName. The resultName variable is to hold list of element found that contain the searchString.

The first for-loop goes through the elements in the allNames array and compare it with the searchString. If any element is found containing the searchString; it is added to the resultName variable.

The second for-loop goes through the elements of the resultName array and output it. The output is empty if no element was found added to the resultName variable.

During comparison, the both string were converted to lower case before the comparison because same lowercase character does not equal same uppercase character. For instance 'A' is not same as 'a'.

You might be interested in
___________ is a document that describes the locations of variables in the data file and lists the assignments of codes to the a
joja [24]

Answer:

codebook

Explanation:

In surveys, codebook is intended to explain variables in the data concerned. It gives information about variable names, variable labels, the text in question and possible variable values, summary statistics and additional notes.

Codebook serves as a guide because in surveys, coding is commonly used and need to be described in more detail.

8 0
3 years ago
PLEASE HELP I HAVE A TEST RIGHT NOW!!!
lyudmila [28]

Answer:

The algorithm is as follows:

1. START

2. ARRAY2D[3][4]

2. FOR ROW = 0 to 3

2.1 FOR COL = 0 to 2

2.1.1 IF ARRAY2D[ROW][COL] > 7

2.1.1.1 PRINT

2.1.2 END IF

2.2 END FOR

3 END FOR

4. STOP

Explanation:

This begins the algorithm

1. START

This creates a 2d array of 3 column and 4 rows

2. ARRAY2D[3][4]

This iterates through the rows

2. FOR ROW = 0 to 3

This iterates through the columns

2.1 FOR COL = 0 to 2

Check if array element is greater than 7

2.1.1 IF ARRAY2D[ROW][COL] > 7

Print the element, if true

2.1.1.1 PRINT ARRAY2D[ROW][COL]

The following ends the condition and iterations

<em>2.1.2 END IF</em>

<em>2.2 END FOR</em>

<em>3 END FOR</em>

This ends the algorithm

4. STOP

3 0
3 years ago
Victor works for a telemarketing company that is on a very tight budget. He has been tasked with finding a method for the compan
snow_tiger [21]
I'd say a wiki was the best option for them. Anyone can edit it from anywhere, which is vital when no one's in the office at the same time and some work from home.
4 0
3 years ago
Read 2 more answers
Which of the following recommendations should you follow when placing access points to provide wireless access for users within
Colt1911 [192]

A WLAN, or wireless local area network, is created by an access point, typically in an office or big building. An access point transmits a Wi-Fi signal to a predetermined region after connecting via an Ethernet cable to a wired router, switch, or hub. Thus, option C is correct.

<h3>What access points to provide wireless access for users?</h3>

You may determine your wireless access point IP address by going to the settings menu of your adapter if you're already connected to the network via Wi-Fi or Ethernet.

Therefore, Open Network & Internet settings can be accessed by selecting with the right mouse click on the network icon in the system tray.

Learn more about wireless access here:

brainly.com/question/13073711

#SPJ1

6 0
1 year ago
Explain which are of the brain you think might light up to show that you are telling a lie and why
agasfer [191]
The left side because the right side of the brain handles stuff more on the line of shapes and objects
6 0
3 years ago
Other questions:
  • What sends massive amounts of email to a specific person or system that can cause that user's server to stop functioning? mail b
    6·1 answer
  • While doing online research you enter this keyword search with a truncation character: man* Which of the following would not be
    15·1 answer
  • Kyle asked his supervisor which type of computing model was used when the enterprise first started. She explained that the organ
    14·1 answer
  • Your digital footprint says a lot about you, but not everything is true or accurate. When you're a high school or college studen
    13·1 answer
  • Consider a DataFrame named df with columns named P2010, P2011, P2012, P2013, 2014 and P2015 containing float values. We want to
    9·1 answer
  • You are a network administrator for your company. The network consists of a single Active Directory domain. All servers run Wind
    7·1 answer
  • What would a bar graph best be used for? State why and give 2-3 examples of things you could demonstrate with a bar graph
    5·1 answer
  • B) The company's chief financial officer recognizes the need for an upgrade to the smart watches, but does not understand why th
    8·1 answer
  • Which original VPN protocol is supported by most platforms but offers low levels of security?
    12·1 answer
  • Chantal has configured the network at her company's new headquarters with a number of VLANs. All devices joined to the individua
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!