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

Shrink-wrap, box-top, and click-wrap agreements are inherent to e-commerce. How you feel about them often depends on whether you are the vendor or purchaser. What are the best practices to assure shrink-wrap, box-top, and click-wrap agreements are legal? What are the best ethical practices that the e-commerce industry should adopt?

Answers

Answer:

Shrink-wrap, Box-top, and Click-wrap Agreements

a) The best practices to assure that shrink-wrap, box-top, and click-wrap agreements are legal include  

1) having e-commerce terms and conditions separate from the normal trade terms and conditions,  

2) ensuring that customers agree to the terms before entering into a transaction, and  

3) laying the code of conduct for all visitors interacting with your site or doing any business transaction on your site.

b) The best ethical practices that the e-commerce industry should adopt are:

1) Put additional layers of protection like a web application firewall to their websites.  

2) Ensure they always adhere to PCI (Payment Card Industry) compliance guidelines.

3) They should not store customers' data which they do not need.

4) Ensure privacy and security of customers' data.

5) Establish trust by safeguarding intellectual property rights.

6) Consider some environmental issues (customers care about them).

Explanation:

a) Websites' Terms and Conditions (T&C) establish some form of legal contract between the organization and its clients.  

b)To ensure that organizations that process, store, or transmit credit card information maintain secure online environment, they are required to comply with PCI DSS.  It is a set of Payment Card Industry requirements for all organizations involved in the use of online cards for payment for their goods and services.

A database has one physical schema and one conceptual (logical) schema but many external schemas (views).
a) True
b) False

Answers

Answer:

true

Explanation:

A database has one physical schema and one conceptual (logical) schema but many external schemas (views): a. True.

A database refers to a structured (organized) collection of data that are stored on a computer system and usually accessed in various ways such as electronically.

In database management, a database schema can be defined as a structure which is typically used to represent the logical design of the database. Thus, it denotes how data are stored (organized) and the relationships existing in a database management system (DBMS).

Generally, there are two (2) main types of a database schema and these include;

Physical database schema: it is only one per database.Conceptual (logical) schema: it is only one per database.

However, there are multiple number of external schemas (views) for each database because it is what an end user is interested in.

Read more on database here: https://brainly.com/question/3259292

Allison is writing a program in Java and keeps getting an error. Which line of code is causing the error?

A. Int a = 0, b = 3, c;
B. for(i = 0, i <= 13, i++) {
C. c = (a * 2) + i;
D. System.out.println(c);

}

Answers

B will cause an error.

Allison needs to declare a type for variable i and use semi-colons.

The for statement should be for(int i = 0; i <=13; i++){

Write a script that inputs a line of plaintext and a distance value and outputs an encrypted text using a Caesar cipher.
The script should work for any printable characters. An example of the program input and output is shown below:
Enter a message: Hello world!
Enter the distance value: 4
Output: Lipps${svph%

Answers

Answer:

def encrypt_text(text,value):

   encoded = ""

   for i in range(len(text)):

       char = text[i]

       if (char.isupper()):

           encoded += chr"po"ord'po'char'pc' + value -65'pc' % 26 + 65'pc'

       else:

           encoded += chr'po'ord'po'char'pc' + value -97'pc' % 26 + 97'pc'

   return encoded

plaintext = input("Enter sentence of encrypt: ")

dist_value = int(input("Enter number: "))

encrypted = encrypt_text(plaintext, dist_value)

print(encrypted)

Explanation:

The python program above is a Ceasar cipher implementation. The encrypt_text function is defined to accept text input and a distance value, which is used to encrypt the plaintext.

The user can directly input text and the distance value from the prompt and get the encrypted text printed on the screen.

Help me! I’ll mark you brainly and give extra points!

Answers

Answer:

52 5,

Explanation:

Create a new program with a struct, Data, that contains: an int a char[80] Write a function newData(char[]), that takes char[] as a parameter

Answers

Answer:

#include <iostream>

#include <cstring>

using namespace std;

struct Data {

   int userId;

   char name[80];

}

void newData(string data char[]){

   int counts= 0;

   struct Data name;

   data.userId = ++counts;

   data.name = char[];

   cout<< data.userId << "\n"<< data.name ;

}

int main( ) {

   char myName;

   string mydata;

   cin>> myName;

   cin>> mydata;

   newData( myName, mydata);

}

Explanation:

The c++ source code above stores its data in a struct called "Data". The function newData dynamically creates new data from the struct defined.

Other Questions
The point-slope form of the equation of a line that passes through points (8, 4) and (0, 2) is y - 4 = (x 8). Whatis the slope-intercept form of the equation for this line?O y = 1 x - 12O y = -x-4O y=+*+2O y=x+6 A house costs $18,000, which is 9/10 the cost of a car. A motorcycle costs 1/5 the cost of the car, or 4/5 the cost of 100 cards. How much is the cost of 30 cards?PLZ PLZ PLZ PLZ PLZ HELP!!!!!!!!!!!!! In this activity, you will write five sentences in Spanish describing your family relationships. Form sentences that include the words for parents, sisters, brothers, grandparents, and fiancs (if any). Submit the response to the teacher by way of the drop box.Example:Mi padre es Jorge. l es esposo de Abby. Abby es mi madre.Mi padre es Jorge. l es esposo de Abby. Abby es mi madre. Tengo dos hermanos mayores y una hermana menor. Vivimos en una casa pequea en Madrid. Mi padre es un empresario y mi madre es una profesora de ingls. Mis abuelos viven en Valencia.( i tried looking it up and my teacher said i needed to resubmit it in simpler form :/) Which is true of the standard form of the equation of the line graphed the value of a can be Energy conversion within an animal cell would be severely limited by removal of the cell's --F .mitochondriaG .chloroplasts H .plastidsJ .lysosomes Angad,malachy and Jim share 30 in A ratio 1:3:1 how much does each person get A pendulum is transported from sea-level, where the acceleration due to gravity g is 9.80 m/s2, to the bottom of Death Valley. At this location, the period of the pendulum is decreased by 3.00%. What is the value of g in Death Valley Write the next three terms: 7,10,13,16, Prompt: In The Scarlet Letter, I Tituba, Black Witch of Salem, and The Crucible, the authors represent characters who are in some way outside of their societies. In a written response, analyze the ways in which these representations reflect or challenge the notion that independence defines the American spirit. Support your response with evidence from the text.Step one: Make a declaration/decide on your argumentStep two: List your reasonsStep three: Connect - write your thesis What are some of the important causes and effects of the American Revolution? can someone help me with this (6) (7)I need a step by step process. How long did it take the Mongol Empire toconquer more land than the RomanEmpire? The length of a rectangle is 4 inches greater than the width. The perimeter of the rectangle is 24 inches. What are the dimensions of the rectangle A number decreased by 22 is 44. Which equation can be used to solve this problem __ is a famous neurologist who prescribed "rest cures for anyone suffering from depression. This "cure" kept people, mostly women, from doing anything that engaged their minds reading, writing, thinking - and confined them to bed. ___ was Gilman's (the author) doctor when she was depressed, and her experience with his treatment led to her writing of "The Yellow Wallpaper." silas weir mitchell, louis pasteur, or jonas salk Which answer best describes the portion of the chart labeled M? 2011 FLVS (4 points)The president presents drafts of bills to the House of Representatives and the Senate.The president appoints subcommittees to review bills from the House of Representatives and the Senate.President receives bills from Congress which he approves or vetoes.The president reviews vetoed bills from Congress and can override the vetoes. Help me! Ill mark you brainly and give extra points! What does Confucius consider the Root of Humanity Which of the following relationships represents joint variation?