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
mamaluj [8]
3 years ago
15

Write a program which takes a string and a word from the userand search that word in the string and count how many timesthat wor

d comes in the string.
Computers and Technology
1 answer:
GuDViN [60]3 years ago
7 0

Answer:

Following is the Java Code:-

import java.io.*; // package of java input output

import java.util.*; // package for using scanner class  

class Main{  

static int count(String str, String word) // create as function

{  

String a1[] = str.split(" "); // splitting the string by space

int c = 0; // initialization of count variable

for (int k = 0; k< a1.length; k++)  

{  

if (word.equals(a1[k])) // match the string to word if condition is matched

c++; // increment of count

}  

return c++;  

}  

public static void main(String args[]) // main method

{  

Scanner ob1 = new Scanner(System.in); // Creating a Scanner object

System.out.println("Enter the string:");

String str1,word1;  

str1= ob1.nextLine();

System.out.println("Enter word you want to search without spaces:");

word1 = ob1.nextLine();

System.out.println(count(str1, word1)); // calling and printing ther word

}  

}

Output:-

Enter the string:

deep das dev das

Enter the word you want to search without spaces :

das

2

Explanation:

I have taken an array of strings to store the words in the string entered and checking the word entered is equal to any word in the string if it is then updating the count.After that returning the count .

You might be interested in
What kind of company would hire an Information Support and Service employee?
Anni [7]
A service company would hire an Information Support and Service employee.

hope it helps you!
6 0
4 years ago
Read 2 more answers
if you want to exclude a portion of an image which option should be chosen?? A. Arrange B. Position C. Crop D. Delete
Anuta_ua [19.1K]
It would be C- crop. This allows you to specifically delete parts of the image using drag and drop features. Hope this helps!
3 0
3 years ago
listen to exam instructions a small business called widgets, inc. has hired you to evaluate their wireless network security prac
Alex

Following actions could you most likely advise the client taking to strengthen the security of their wireless network-

  • Change the default SSID to anything different.
  • Turn off SSID broadcasting.
<h3>Explain the term wireless network security?</h3>
  • Designing, putting into practice, and ensuring security on such a wireless computer network are all parts of wireless network security.
  • A wireless computer network is further protected by this subset of network security.
  • Wireless security is another name for wireless network security.

For the stated question-

  • Disabling SSID broadcast and changing the network name are advised.
  • By disabling SSID, the network name won't be displayed on devices looking for a network can connect to, and so by changing the name, it will be impossible for anyone who already knows the old name to connect.
  • Both of which significantly boost security.

To know more about the wireless network security, here

brainly.com/question/28257213

#SPJ4

3 0
2 years ago
Create a Python program that:
Charra [1.4K]

Answer:

```

file = open("trips.txt","r")

file = file.split("\n")

trip_date = []

fuel_used = []

miles_traveled = []

for i in file:

   trip_date.append(i.split(", ")[0])

for i in file:

   fuel_used.append(i.split(", ")[1])

for i in file:

   miles_traveled.append(i.split(", ")[2])

```

This should put the data in their own lists (i didn't test it) but im not going to solve everything for you. The rest is for you to tinker with. You shouldn't throw your question at us and expect an answer. This is the most that I will give you.

Explanation:

4 0
3 years ago
What is the use of tag in XML sitemap?
podryga [215]

Answer:

It works as a roadmap which tells search engines what content is available on the website and leads search engines to most important pages on the site. The standard XML tag used for sitemaps can be described as a schema and is used by all the major search engines.

Explanation:

mark me brainliest!!

8 0
2 years ago
Other questions:
  • In the software development life cycle, what is the role of participants in the planning phase? The participants’ role in the pl
    6·1 answer
  • ______ is an example of unauthorized access to your computer or accounts.
    14·1 answer
  • 10. Question
    15·1 answer
  • Write the definition of a method named countPos that receives a reference to a Scanner object associated with a stream of input
    13·1 answer
  • In which circumstances would the view side by side feature be useful or helpful.
    15·2 answers
  • Factors to consider while selecting a software to use​
    14·1 answer
  • Assume the availability of a function is_prime. Assume a variable n has been associated with positive integer. Write the stateme
    15·1 answer
  • Write the definition of a function isSenior, that receives an integer parameter and returns true if the parameter's value is gre
    13·1 answer
  • In which generation of computers are we in?​
    9·1 answer
  • I don't get the width and height part (PLEASE HELP WILL GIVE BRAINLIEST ANSWER)
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!