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
navik [9.2K]
3 years ago
3

Write a program which takes a String input, and then prints the number of times the string "sh" appears in the String (s and h c

an be any case).
Hint - remember there are String methods which return a copy of the String it is called on with all letter characters changed to the same case.

Sample run

Input String:
She sells seashells on the seashore
Contains "sh" 3 times.
Computers and Technology
2 answers:
Anna35 [415]3 years ago
7 0

import java.util.Scanner;

public class{

public static void main(String[ ] args){

Scanner reader = new Scanner(System.in);

System.out.println(“Input String:”);

String input = reader.nextLine();

input = input.toLowerCase();

int count = 0;

for (int i = 0; i < input.length()-1; i++){

if (input.substring(i, i+2).equals(“sh”)){

count++;

}

}

System.out.println(“Contains \”sh\” ” + count + “times.”);

}

}

Soloha48 [4]3 years ago
4 0

import java.util.Scanner;

public class JavaApplication61 {

   

   public static void main(String[] args) {

       Scanner scan = new Scanner(System.in);

       System.out.println("Input String:");

       String text = scan.nextLine();

       text = text.toLowerCase();

       char c = ' ', prevC = ' ';

       int count = 0;

       for (int i = 0; i < text.length(); i++){

           c = text.charAt(i);

           if (c == 'h' && prevC == 's' && i >= 1){

               count += 1;

           }

             

            prevC = c;

       }

       System.out.println("Contains \"sh\" "+count+" times.");

       

       

   }

   

}

This works for me. Best of luck.

You might be interested in
You have installed a point-to-point connection using wireless bridges and Omni directional antennas between two buildings. The t
kozerog [31]

Answer and Explanation:

Omnidirectional antenna are those antennas which receives the signals from multiple directions equally.These are the antennas that cannot  get the signal from a particular direction thus gives the low throughput.

To get high throughput, directional antennas should be installed because they receive the signal from a particular direction only .Thus the signal received from these antenna work for a certain area.Example-Television antenna at homes are directional antennas names as Yagi-uda antennas.

3 0
4 years ago
What type of devices are the keyboard and the mouse?
Angelina_Jolie [31]
 A keyboard is the primary device to enter text that consists of alphabet keys, numeric keys and other specialized keys. a mouse may include one or more buttons and a scroll wheel and works by moving across a smooth surface to signal movement of the pointer. Both are plug and play( PnP).
6 0
3 years ago
Read 2 more answers
A computer has been stored, uncovered, in a dusty closet for several months. Why might this situation cause the operating system
Nezavi [6.7K]

Answer: ....

Dust and debris can cause performance deterioration.

Explanation:

Dust is a problem from the standpoint of blocking fan vents, or, if deep enough, actually insulating parts, causing overheating, but unless it contains substantial amounts of corrosive or conductive material (in which case you shouldn’t be breathing it), it won’t damage the electrical components (beyond any overheating damage).

What could happen, in some circumstances, is condensation inside the box, mixing with dust and creating a conductive sludge. This would generally only occur if you bring the box in from an extremely cold environment (below 0C, roughly) into a humid indoor environment. The protection from this is to wrap the box tightly in plastic before bringing it indoors, and leave it wrapped for a couple of hours, while it has time to warm up.

3 0
3 years ago
Joanna accidentally leaned on her keyboard and repeatedly typed the letter z. How can she fix this mistake?
Brut [27]

Answer:

just press delete

Explanation:

5 0
3 years ago
Read 2 more answers
Mary uploaded some images on her website. She chose an image and downloaded it. She found that the image she saw on screen did n
kondor19780726 [428]
It could be A or B, with a guess that it’s A. Many websites require images to be compressed on uploading so that it takes less of the site’s database storage, but the wording leads me to believe it may be B. Any thoughts?
4 0
3 years ago
Other questions:
  • ________ is an open-source program supported by the Apache Foundation that manages thousands of computers and implements MapRedu
    5·1 answer
  • Your uncle spent most of his teen years in a hospital undergoing treatment for a severe physical illness. As an adult, he is rat
    10·1 answer
  • Chunking is a good strategy for completing large assignments because it makes the work
    15·1 answer
  • You are responsible for tech support at your company. You have been instructed to make certain that all desktops support file an
    15·1 answer
  • What hernia repair codes can be reported with add-on code 49568?
    6·1 answer
  • Long-tail keywords are:
    9·1 answer
  • Which of the following statements is not true? Group of answer choices
    9·1 answer
  • Tim is creating a page to display his poker club’s set of rules. He has main categories and subcategories along with about a par
    12·1 answer
  • An example of a host-based intrusion detection tool is the tripwire program. This is a file integrity checking tool that scans f
    8·1 answer
  • dion training just installed a new webserver within a screened subnet. you have been asked to open up the port for secure web br
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!