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
Justine was interested in learning how to play the piano. Before she was allowed to even play the piano, she has had to learn
Setler [38]

Answer:

A

Explanation:

The answer is A because, to be novice at something that means one is new to and is inexperienced at said activity.

3 0
3 years ago
Read 2 more answers
Write the code for invoking a method named sendObject. There is one argument for this method which is of type Customer. Assume t
kodGreya [7K]

Answer:

sendObject(John_Doe);

Explanation:

The above code has been written in Java.

Since the calling class is the same that declares it, to invoke the method, simply call its name with its argument(s) in a pair parentheses. The name of the method is "sendObject" and its argument is a reference to an object of type Customer saved in a variable called "John_Doe". This can be written as follows:

sendObject(John_Doe);

Hope this helps!

3 0
3 years ago
What kinds of circumstances would lead you to writing a function versus using a loop? please explain in simple terms
GREYUIT [131]

Answer:

1. You want to use parameters

2. You don't want your program to run multiple times

3. You want to call that snippet of code throughout your program

hope this helped :D

5 0
3 years ago
Explain benefits and disadvantages of using BNC over F-Type connectors on coaxial cables
Leokris [45]

Answer:

The benefits and disadvantages of using BNC over F-Type connectors on coaxial cables are;

The <em>benefits </em>of the BNC includes;

1) Easy connect and disconnect for a more rapid connection unlike the F-Type connector which is a screw connector

2) Reduction on stress on the termination of the coaxial cable

3) Appropriate in systems that see frequent reconfiguration unlike te F-Type connector that is permanently attached

4) Prevent unwanted disconnection ensuring image consistency by locking into place

5) Can extend to 300 ft.

The <em>disadvantages</em> of the BNC connectors are;

1) A separate power supply for the cable is required

2) Is used only for video transmission

3) Cannot be used for audio

4) The center wire is not easily visible like those of the F-Type connector which serves as a pin

5) The BNC connector is not watertight like the F-Type connectors

6) There are no provision for properly and securely attaching the cable to the camera for field work such that it can be easily disconnected while in use unlike the F-Type connectors

7) It is not as easy to manufacture like the F-Type connector and it is more expensive

8) The installation of the BNC connector on a coaxial cable is more intricate and the center cable is hidden from view after the BNC is attached thereby making it not possible to see if there is an error in installation which is unlike the F-type connector that takes less than 30 seconds to be attached to a cable

9) The F-Type connector provides more cost savings during installation than the BNC connector

Explanation:

The BNC connector is a type of bayonet connector used more frequently on CCTV systems. The benefits of the BNC includes;

The F-Type connectors are usable on SATV, CATV, and Digital TV where they are used together with RG6 or RG11 cables

3 0
3 years ago
A(n) ________ event is an alert that is generated when the gossip traffic enables a platform to conclude that an attack is under
Allisa [31]

Answer:

B. DDI

Explanation:

A(n) DDI event is an alert that is produce or invoke when the gossip traffic allow a platform to conclude that an attack or potential attack is under way.

A device driver is a computer program that operates or controls a particular type of device that is attached to a computer system.

A driver provides or supply a software interface to hardware devices which enable the operating systems and other computer programs to access hardware functions without needing to know the exact details in respect of the hardware being used.

DDI means Device Driver Interface

A driver relate or communicate with the device via the computer bus or communications subsystem to which the hardware is connected. Whenever a calling program invokes a routine in the driver, the driver will subsequently transmit commands to the device.

7 0
3 years ago
Other questions:
  • Ron is creating building blocks in Word. How can he make the building blocks that he created available?
    11·2 answers
  • 22 If you are involved in a violation and you do not have insurance to comply with the __________________, your driver license a
    9·2 answers
  • What is it called when you make a reference in the text of a document alerting the reader that you are using information from an
    10·1 answer
  • Assume the availability of class named DateManager that provides a static method, printTodaysDate, that accepts no arguments and
    11·1 answer
  • Read the excerpt from The Code Book. Other attacks include the use of viruses and Trojan horses. Eve might design a virus that i
    13·1 answer
  • Write a program that produces an expense report for a trip to Lagos, Nigeria. Use the Internet to research the cost to travel to
    13·1 answer
  • What's the smallest part of a computer
    8·2 answers
  • What is an outcome in a game? Don't search google just give me an answer
    9·1 answer
  • What does the following process describe?
    10·1 answer
  • What kind of AR target category makes sense for a playing card with a picture on it?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!