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
Bess [88]
4 years ago
14

Write a method named countMatching(). It has two parameters: a String and a character. The method returns a count of how many ti

mes the character parameter appears in the String parameter. Case matters. For example, 'A' is not the same as 'a'. You only need to write the countMatching() method and nothing else (do not modify the main() method provided below). Note, however, that your method must work for any parameters passed, not just the example below.

Computers and Technology
1 answer:
andreev551 [17]4 years ago
4 0

Answer:

Check the explanation

Explanation:

public static int countMatching(String s, char c) {

   int count = 0;

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

       if (s.charAt(i) == c)

           ++count;

   }

   return count;

}

Method in a complete Java program

public class FizzBuzz {

/* sample run:

    * z appears 2 time(s) in FIZZbuzz

    */

   public static void main(String[] args) {

       String s = "FIZZbuzz";

       char c = 'z';

       int count = countMatching(s, c);

       System.out.printf("%c appears %d time(s) in %s%n", c, count, s);

   }

   // Put your countMatching() method here:

   public static int countMatching(String s, char c) {

       int count = 0;

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

           if (s.charAt(i) == c)

               ++count;

       }

       return count;

   }

}

z appears 2 time(s) in FIZZbuzz Process finished with exit code

You might be interested in
Plz help! 3 questions! 1.The ideal light to use is.... A.front light B.a combination of side and back light C.a combination of f
defon

There are different kinds and types of light bulb, though light is produce by power, current and resitance.1. The ideal light to use is a front light which it can lighten the dark room depends on the radius of the light or the reflector.

2. Incandescent light generally comes from a bulb like one found in a living room where there are different shapes and lights that have different watts which it differs on how much light it produces or the current and resistance of the light reflector.

<span>3.Incandescent light has a type of a color cast of neutral contrast which also depends on the bulb shapes and kinds. Now we are using LED light to conserve power/energy.</span>

4 0
3 years ago
Which osi model layer manages data encryption?
Hoochie [10]
The presentation Layer manages data encryption.
7 0
4 years ago
It's so eazy
Dmitrij [34]

Answer:

  1. true
  2. true
  3. false
  4. true
  5. true
4 0
3 years ago
Read 2 more answers
What are the features of a computer speaker​
Aliun [14]
Some computer speakers have equalization features such as bass and treble controls. Bluetooth speakers can be connected with a computer by using an Aux jack and compatible adaptor. More sophisticated computer speakers can have a subwoofer unit, to enhance bass output.
Hope that helps....it on googIe
6 0
3 years ago
Which generation is characterized by conspicuous consumption?
yulyashka [42]

Answer:

The is the type of consumption is typically associated with the wealthy but can also apply to any economic class.

Explanation:

7 0
3 years ago
Other questions:
  • 2. To learn the proper way to set up a table of contents, editors can use a A. style manual. B. dictionary. C. grammar checker.
    15·1 answer
  • This procedure protects against the loss of data
    5·1 answer
  • The process of _____ determines what volume a system can handle by comparing its performance to standards in the industry.
    7·1 answer
  • What did I do wrong? May you please correct it for me...I was also looking on how to delay when it prints. Like when it prints a
    9·1 answer
  • Instructions:Select the correct answer.
    9·1 answer
  • Consider a file currently consisting of 100 blocks. Assume that the file control block (and the index block, in the case of inde
    12·1 answer
  • What is essence of computer systems and networks?​
    9·1 answer
  • Which of the following statements best describes the relative amount of content held by digital libraries vs. the amount held by
    12·1 answer
  • Which fund classification would a focus on only stocks of technology companies match?
    10·1 answer
  • Which tab should you use to change the text font color in your presentation?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!