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
vova2212 [387]
3 years ago
13

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:
Computers and Technology
1 answer:
riadik2000 [5.3K]3 years ago
3 0

Answer:

import java.util.Scanner;

public class ANot {

   public static void main(String[] args) {

       System.out.println("Enter a character");

       Scanner in = new Scanner(System.in);

       char character = in.next().charAt(0);

       System.out.println("Enter a string");

       String string = in.next();

//Calling the method        

System.out.println(countChar(character,string));

   }

   public static int countChar(char a, String in){

       int counter =0; // initialize counter

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

           if(a == in.charAt(i))

               counter++;

       }

       return counter;

   }

}

Explanation:

This program is written in Java Programming language.

We created a method countChar that returns a integer called counter

Using a for loop in the method we iterate through the string object and check (a == in.charAt(i)) so as to increase counter when ever there is a match.

In the main method a Scanner Class is used to request user to input a character and a string which is passed to countChar when called.

NOTE that this program has considered lower case letters to be different from upper cases as such a is not equal to A

You might be interested in
Help!! Best answer will get Brainliest!!
Eddi Din [679]

Answer:

answer(s):

-set goals

-select a topic

-write down research questions

Hope this helped and sorry for the bold. <3

Explanation:

6 0
3 years ago
Read 2 more answers
Name the different tools used byMMDB.
Anastaziya [24]

Answer:

MMDB stands for the multimedia database as, it the process of collection of the multimedia data or datatypes like images and graphical objects. It basically manages the several types of the data or information and control the multimedia databases.

Different types of tools are:

  •  Video and audio processing system
  •   Artificial intelligence
  •   Graphic design system
  •    Mobile and wireless computing

7 0
4 years ago
A is a program for editing,rearranging and storing text
UNO [17]

Answer:

text editor

Explanation:

hope it helps

4 0
3 years ago
Read 2 more answers
Because log-on procedures may be cumbersome and tedious, users often store log-on sequences in their personal computers and invo
diamong [38]

Answer:(C) Anyone with access to the personal computers could log on to the mainframe.

Explanation:

It is no doubt that log on procedures are cumbersome so what most users do is that they store log on sequences in their computer so that they could use the main frame facilities whenever they access it the second time.

Here we have to identify the associated risk with this approach.

This process could lead to access of the computer system to users and thereby making all the data available in the system vulnerable. So option C is correct.

option (A) is incorrect as the back up option who also be affected when the system is accessible to anyone.

option (B) is incorrect because it has nothing to do anything with training of the personnel.

option (D) is incorrect because it one has nothing to do with the physical system what vulnerable reside is inside the system.

7 0
3 years ago
A(n) ____________________ can improve system performance when two devices have different data transfer rates, as when copying mu
defon

Hello there

the answer to the question is

<u><em>Buffer</em></u>

hope this helps

Best Regards Queen Z

8 0
3 years ago
Other questions:
  • How do you mark somebody the brainliest?
    14·2 answers
  • Which tab is used to edit objects on the slide master and layouts
    10·1 answer
  • Name two common methods for performing dependency injection.
    15·1 answer
  • Web and mobile applications are created for users to only read information. True False
    15·2 answers
  • What is some advice you would give someone who is just starting online learning 2 sentences
    8·1 answer
  • The ________ is responsible for the Internet's domain name system and the allocation of IP addresses.
    12·1 answer
  • MyProgramming Lab
    12·1 answer
  • Find true or false. A hacker is hacking software with access in sensitive information from your computer​
    9·1 answer
  • Need help asap
    5·1 answer
  • With _________, it is easy to target a specific geographic location. Which answer completes the blank in the sentence?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!