20 pts, please write in JAVA. need this ASAP
In the Lesson Slides for this activity, we developed a method findChar for figuring out if a character was in a String.

The implementation was:

public boolean findChar(String string, String key)
{
for(int index = 0; index < string.length(); index++)
{
String character = string.substring(index,index+1);
if(character.equals(key))
{
return true;
}
}
return false;
}
However, there is a much more efficient and simple algorithm that we can use to determine if a character is in a String. Using the method signature public boolean findChar(String string, String key), figure out a more efficient method with a lower exection count.

Hint: We’ve learned a couple of methods that can tell us what index a character is at - can we use those to determine if the character is in a String?

Answers

Answer 1

public class JavaApplication78 {

   public boolean findChar(String string, String key){

       if (string.contains(key)){

           return true;

       }

      return false;

   }

   public static void main(String[] args) {

       JavaApplication78 java = new JavaApplication78();

       System.out.println(java.findChar("hello", "h"));

   }

   

}

First I created the findChar method using the contains method. It checks to see if a certain sequence of characters is in another string. We returned the result. In our main method, we had to create a new instance of our main class so we could call our findChar method.


Related Questions

Which of the following would be appropriate to create using the CMYK color model?

Select all that apply.

a printed takeout menu a printed takeout menu , ,

a photography blog a photography blog , ,

a tri-fold brochure a tri-fold brochure , ,

a mobile app logo

Answers

Answer:

B, and C

Explanation:

they look like the only two answers that make sence

What is payload?
a block of data inside the packet
a block of data transmitted across a network
the maximum amount of data a network can transmit
a 32-bit numeric address

Answers

Answer:

a block of data inside the packet

Write a multi-way if statement that compares the double variable pH with 7.0 and makes the following assignments to the bool variables neutral, base, and acid:

Answers

Answer:

try:

   pH = float(input("Enter number between 0 to 14: "))

except ValueError:

   print("input must be a number")

if pH < 7:

   print("pH is Acidity")

elif pH == 7:

   print("pH is neutral")

else:

   print("pH is Base/alkaline")(

Explanation:

The try and except statement is used to check if the input is a number, if its not, the print statement is displayed. The nested if statement compares the pH input to know if it is an acid, base or neutral.

PLzzzzzz help me!! I will mark brainiest to the one who answers it right!!
Answer it quickly!!

Write a pseudo code for an algorithm to center a title in a word processor.

Answers

Answer: abstract algebra

Explanation: start with the algorithm you are using, and phrase it using words that are easily transcribed into computer instructions.

Indent when you are enclosing instructions within a loop or a conditional clause. ...

Avoid words associated with a certain kind of computer language.

Answer:

(Answers may vary.)

Open the document using word processing software.

In the document, select the title that you want to center. The selected word is highlighted.

On the Menu bar, select the Format tab.

In the Format menu, select Paragraph.

The Paragraph dialog box opens with two sub tabs: Indents and Spacing, and Page and Line Breaks. The first tab is selected by default.

Adjust the indentation for the left and right side. Ensure that both sides are equal.

Preview the change at the bottom of the dialog box.

Click OK if correct, otherwise click Cancel to undo changes.

If you clicked OK, the title is now centered.

If you clicked Cancel, the title will remain as it is.

Explanation:

I took the unit activity

How do I do these? I dont understand.

Answers

I don’t understand either, I would suggest contacting your teacher or maybe searching up videos or tutorials on how to solve such a problem.

How would you reply to an email message you've received that has multiple recipients, all of whom you would like to see your reply?

Answers

Answer:

depends on the app. if it's in google you can hit the reply all button and that will send the reply to all people or you can copy the email addresses from the original email into a new email

Answer:

the answer is c :D

Explanation:

One of the primary principles of the Rapid Application Development methodology is early prototyping of the _______ in the development cycle

Answers

Answer:

Software Applications

Explanation:

Rapid Application Development (RAD) also is an agile project management strategy used in the development of software. RAD is also referred to as Rapid Application Building (RAB).

Its greatest advantage is that it reduces the time taken to churn out a program and this is why a lot of developers are now adopting it.

This is made possible by reducing the amount of time and effort spent on planning and increasing the amount of energy spent on creating prototypes.

Other merits of this methodology are:

It reduces the risk associated with the project by ensuring that the program is first used as a prototype rather than the real deal. It ensures better quality. When users interact with the prototypes, they are able to provide very useful feedback that goes back into development to enhance the quality of the project.

Cheers!

True or false: Simultaneous multithreading (SMT) uses threads to improve resource utilization of a dynamically scheduled, out-of-order processor.

Answers

Answer:

True

Explanation:

Simultaneous multithreading or otherwise called, SMT that is a technique that us used for improving the total and overall efficiency of superscalar CPUs with hardware multithreading. Simultaneous Multithreading allows different types of independent threads, ability to execute and then eventually take optimum and much better use of the resources that is provided by modern processor architectures. Multithreading can not only allow multiple threads to be executed simultaneously in a single CPU core, it also allows multiple tasks some of which are different page tables, different I/O permissions, and others to be executed

Other Questions
A pound of ground beef costs $5. what is the cost of 1/2 pound? ill mark brainliestSolve the proportion.b/36=5/9b= 1.Name in order the Major Religions of the world with origin, messengers, religious texts and sects of each. I dont understand this The ratio of red marbles to blue marbles in a bag is 4 to 3. Which of the following could be the number of red and blue marbles in the bag? Delph Company uses a job-order costing system and has two manufacturing departmentsMolding and Fabrication. The company provided the following estimates at the beginning of the year:Molding Fabrication TotalMachine-hours 23,000 33,000 56,000Fixed manufacturing overhead costs $790,000 $200,000$990,000Variable manufacturing overhead cost per machine-hour $5.60 $5.60During the year, the company had no beginning or ending inventories and it started, completed, and sold only two jobsJob D-70 and Job C-200. It provided the following information related to those two jobs:Job D-70: Molding Fabrication TotalDirect materials cost $ 371,000 $ 328,000 $ 699,000Direct labor cost $ 240,000 $ 160,000 $ 400,000Machine-hours 16,000 7,000 23,000Job C-200: Molding Fabrication TotalDirect materials cost $ 290,000 $ 210,000 $ 500,000Direct labor cost $ 100,000 $ 240,000 $ 340,000Machine-hours 7,000 26,000 33,000Delph had no underapplied or overapplied manufacturing overhead during the year.Required:1. Assume Delph uses a plantwide predetermined overhead rate based on machine-hours.a. Compute the plantwide predetermined overhead rate.b. Compute the total manufacturing cost assigned to Job D-70 and Job C-200.c. If Delph establishes bid prices that are 150% of total manufacturing cost, what bid prices would it have established for Job D-70 and Job C-200?d. What is Delph's cost of goods sold for the year? HELP PLEASE EASY 10 POINTS Who received benefits from settlement houses in the late 1800s and early 1900s?young women from wealthy familiesimmigrants who had recently come to Americareformers like Jacob Riis and Lincoln Steffensmembers of the middle-class people who needed a place to live - What is the equation and the slope of the line shown on the grid? An entrepreneur would most likely be interested in Question 4 of 25True or false: f(x) is a function.8120f(x)A. True B. False Which one would give you a jolt?an electric companyan electric companyan electric personalityan electric personalityan electric shockan electric shockan electric typewriteran electric typewriter How did the Protestant Reformation serve as a CHANGE for Christian beliefs in the 1450-1750 time period? HELP ME PLEASE 40 POINTS Calculate the average speed of a boat that travels 600 meters in 40 seconds. What is an organelle? What type of cells have a high concentration of mitochondria? 1) skin cells 2) blood cells 3) heart cells 4) nerve cells What is the constant in 2m + 3m - m Need help ASAP please help What do you think this is? Why might it be important to Islam?