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
ki77a [65]
3 years ago
7

Write a program whose input is a character and a string, and whose output indicates the number of times the character appears in

the string.
Ex: If the input is: n Monday,
the output is: 1
Ex: If the input is: z Today is Monday,
the output is: 0
Ex: If the input is: n It's a sunny day,
the output is: 2
Case matters. n is different than N.
Ex: If the input is: n Nobody,
the output is: 0

Your program must define and call the following function that returns the number of times the input character appears in the input string.

int CountCharacters(char userChar, string userString)
Computers and Technology
1 answer:
Sladkaya [172]3 years ago
4 0

Answer:

The program written in Java is given in the explanation section

Explanation:

public class num9 {

//Defining the method CountCharacters()

   public static int CountCharacters(char userChar, String userString){

       int c = userString.length();

       int count=0;

       for(int i=0; i<c; i++){

           if(userString.charAt(i)==userChar){

               count++;

           }

       }

       return count;

   }

//Main method begins here

   public static void main(String[] args) {

   char n ='n';

   String word = "Monday";

//Calling the method CountCharacters()

       System.out.println(CountCharacters(n,word));

   }

}

You might be interested in
What is a header and/or a footer? The bolded subtitle for each section or the footnote on any section Text inserted into the top
USPshnik [31]

Answer:

Option B: Text inserted into the top and bottom margins.

is the correct answer.

Explanation:

Header and footer can further be defined as:

  • Data inserted in the top and bottom margin of the page.
  • This data can be the one which you want to display on each page of the document.
  • Header and footer are the optional data.
  • We can add, document name, Author name, page number etc as header and footer.
  • In order to add header and footer, go to the Insert tab.
  • Locate header/ footer group under this tab.
  • All the settings are available and can be modified easily.

i hope it will help you!

4 0
4 years ago
Select the correct answer,
bazaltina [42]

Answer:

b gyhffhhhgghhhhhhhhhhh

3 0
4 years ago
We all interact with various information systems every day: at the grocery store, at work, at school, even in our cars (at least
Serhud [2]

Explanation:

An information system can be defined as an automated system or not, which is used for the purpose of collecting data and transforming it into relevant information for a given purpose.

Currently, information systems are increasingly used in the organizational environment, for example, as management information systems and decision support systems, which are automated computer systems that provide greater support to a manager's work, due to the amount of data that store and process relevant information to assist in the speed of the decision-making process, since information systems are able to capture a volume of data and analyze it, create standards, find flaws and transmit essential information that makes the manager's work more facilitated and improved.

8 0
3 years ago
What lets you do many things, like write book reports and stories?
Alex
Applicant programs? Is that an option. If not try operating systems
5 0
3 years ago
Consider the following scenario: "You are an assistant to the accounting manager for a small company that sells sports equipment
Rzqust [24]

Answer:

1. Microsoft Excel helps data analysis through different spreadsheet queries and operations options.

2. Input data to the analysis of sales by product is required for the development of formula and extracting results.

3. The information of data source and frequency of report is required to start the work.

Explanation:

1. Microsoft Excel tool can be used to calculate the results of equipment. Obtained results can be displayed in charts and graphs from the excel.

2. Information like the quantity of sold items, remaining items are required to produce accurate, useful analysis.

Before starting assignment accounting manager will be asked the following questions.

1) Where does the input data come from?

2) Is analysis required on a daily basis or once for all provided data?

3) Is Summary is in the form of tabular data, Graphical data, or Both?

4 0
4 years ago
Other questions:
  • A(n) ____ is a collection of one or more program statements combined to perform some action
    14·1 answer
  • Slmething about device for defrosting windscreen?
    5·1 answer
  • A virus is a name given to a small text file that's placed on your computer by the designers of the website when you visit that
    6·1 answer
  • This chapter uses the class rectangleType to illustate how to overload the operators +, *, ==, !=, &gt;&gt;, and &lt;&lt;. In th
    15·1 answer
  • The functions of forums
    15·1 answer
  • Where do you get your news? Is it owned by a large conglomerate does it matter to you who own your local news outlets? why or wh
    5·1 answer
  • Examine the following algorithm.
    9·1 answer
  • Describe a hybird electrical vehical
    12·1 answer
  • Html code to hyperlink home.html​
    5·1 answer
  • For the second one just answer what game engines are please, you don't have to explain.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!