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
Which of the following Web sites would be MOST credible?
pentagon [3]
As of this problem together with the options presented with it, the most probable and the most likely answer for this would be A. a site associated with a local university.

An encyclopaedia site with many contributors can be prone to false information and made-up information. To add to it, some contributors might just be displaying the art of trolling over the internet and some might just be contributing just for the heck of it. A site run by a small, obscure publishing house can become more credible by becoming more renowned. A private site can either be good or bad, depending on the author that set it up. The most credible among the options would be a site associated with a local university.
6 0
3 years ago
You can create a ____ partition to hold files that are created temporarily, such as files used for printing documents (spool fil
LuckyWell [14K]

Answer:

The answer is "Option C".

Explanation:

The /var method can also be used to override the values of the current variable, or generate, and assign values to new variables. It generates a local variable, that can be modified via the -g switch, and other choices are not correct, which can be described as follows:

  • In option A, It is incorrect because it uses to store temporary data file.
  • In option B, It is used by a system administrator, that's why it is incorrect.
  • In option D, It isn't correct because it prints a warning message.
4 0
3 years ago
Which is the correct APA format in books?​
Nina [5.8K]

Answer:

It includes the author's last name, the year, and  a page number. In the reference list, start with the author's last name and initials, followed by the year. The book title is written in sentence case

4 0
3 years ago
Read 2 more answers
if you dont' have access to nessus, which of the following can be used by an attacker to gain information about remote *nix host
galina1969 [7]

The NMap procedure that can be used to help you to gain information about remote *nix hosts is Script Scanning

<h3>What is script scanning?</h3>

The script scanner is known to be tool that acts as a measure component to the real Windows scripting host component as it helps to intercepts scripts, and also scans them before they are said to be executed.

Therefore, The script scanner is known to be tool that acts as a measure component to the real Windows scripting host component as it helps to intercepts scripts, and also scans them before they are said to be executed.

Learn more about Script Scanning from

brainly.com/question/18152781

#SPJ11

4 0
2 years ago
Sophisticated modeling software is helping international researchers (1 point) create more intricate screenplays and movie scrip
tatiyna

Answer: Increase the pace of research in finding and producing vaccines.

Explanation: The modelling software is the software that is used by the international researchers for the purpose of the researching about the vaccines. There are diseases which still don't have any vaccines and they create serious health conditions.

So, researchers are investigating and trying to develop the vaccines with increasing pace.Other options are incorrect because researchers are not looking for the movie scripts, marketing products and evidences.

8 0
4 years ago
Other questions:
  • Implement the function maxLoc(), which returns an iterator at the largest element in a list. template typename list::iterator ma
    14·1 answer
  • In a switch statement, if a break statement is missing, _______________. Select one: a. the default case is automatically execut
    15·1 answer
  • Write algorithm to find (a+b)^2=(a+b)*(a+b)​
    9·1 answer
  • What is the decimal equivalent of the largest binary integer that can be obtained with
    9·1 answer
  • An administrator wants to configure hosts to automatically assign IPv6 addresses to themselves by the use of Router Advertisemen
    14·1 answer
  • Write an algorithm that gets as input your current credit card balance, the total dollar amount of new purchases, and the total
    8·1 answer
  • Define a function is_prime that receives an integer argument and returns true if the argument is a prime number and otherwise re
    9·1 answer
  • 4. When you see ##### in a cell, you should
    14·2 answers
  • Can anyone help explain this?
    13·2 answers
  • What physical disk oriented performance counter should be used to determine the number of requests waiting to be processed by a
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!