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
mixas84 [53]
3 years ago
11

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.
Computers and Technology
1 answer:
grigory [225]3 years ago
4 0

Answer:

import java.util.Scanner;

public class ANot {

   public static void main(String[] args) {

       Scanner in = new Scanner(System.in);

       System.out.println("Please enter a word");

       String word = in.next();

       System.out.println("Please enter a character");

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

       int countVariable = 0;

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

           if(ca ==word.charAt(i))

               countVariable++;

       }

       System.out.println(countVariable);

   }

}

Explanation:

  1. Using the Scanner Class prompt and receive the users input (the word and character). Save in seperate variables
  2. create a counter variable and initialize to 0
  3. Use a for loop to iterate over the entire length of the string.
  4. Using an if statement check if the character is equal to any character in string (Note that character casing upper or lower is not handled) and increase the count variable by 1
  5. print out the count variable

You might be interested in
My computer keeps freezing when trying to start up a new computer (got a new motherboard, CPU, GPU, case, and psu)(had to get a
Alecsey [184]

Try checking if you placed the motherboard in correctly. I am not certain enough.

5 0
4 years ago
What is a software program for navigating the web and displaying websites and pages?
ASHA 777 [7]
The common name for such a program is called a Web Browser. There exist several names for popular browsers, E-Internet Explorer, Mozilla FireFox, Google Chrome, Safari, etc. At the start of the internet, they were not always around, as the internet was mostly used for communications in the US armed forces. In the early-mid 1990's, the first few browsers were created when the first computer OS became mainstream. As the years have gone by, they have since become stronger and faster, and one can do anything on the internet from watching videos, opening a business, talking to your friend or even run a political campaign.
8 0
4 years ago
What can be written to perform a certain number of iterations or to iterate until a specific result is achieved?
OlgaM077 [116]

Answer:

The answer to this question is given below in the explanation section. However, the correct option is B. i.e a for loop.

Explanation:

The correct answer to this question is for-loop. Beause, in the for loop is written to perform a certain number of iterations or to iterate until a specific result is achieved.

for example, to calculate the average of 10 numbers, we use the for loop to iterate statements written in its body 10 times to calculate the average.

when the specific numbers of the iteration are reached it will get terminated.

for example

for (int i=0; i<=10; i++)

{

// perfrom average, code

}

this loop iterate 10 times or less, when it reached above the limit it gets stopped.

however, the other options are not correct, because an ordered data structure is like a list of order data, print function print something to the user or on screen. while an array is like a list of data of the same data type.

7 0
3 years ago
An inner drive to work hard and well is:
Nikolay [14]

A word ethic would be the answer

3 0
4 years ago
You are the security administrator for a bank. The users are complaining about the network being slow. It is not a particularly
bulgar [2K]

Answer:Denial of service

Explanation:Denial of service is the type of attack that is caused to the computer attacks. These attacks basically cause the circumstances such as difficulty in accessing of the website or resource, accessing particular computer system , creation of the traffic in network, This attack occurrence stops or create difficulties for the legal person to access the network .

Therefore, there is the occurrence of the Denial of service(DoS) in the bank's computer network.

3 0
3 years ago
Other questions:
  • A(n) ____ is a system designed to handle only very basic applications with an absolute minimum amount of hardware required by th
    9·1 answer
  • Interactive media professionals are unique among other Information Technology professionals because they
    7·1 answer
  • What cable should i be using to connect my android tablet to the pc?
    13·2 answers
  • What is the drawback of the linear model?
    5·2 answers
  • To give text an outline, you can use which command?
    15·1 answer
  • Within a single program, __________________ allows multiple parts, or threads, to run simultaneously.
    15·1 answer
  • What is the BCC feature used for?
    12·2 answers
  • 100 POINTS!! Help me out please I need help with this!!
    12·1 answer
  • From the philosophical standpoint, especially in the discussion of moral philosophy or ethics, why do we consider “murder” or “k
    9·1 answer
  • How to start the ms excel​
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!