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
Why is it useful for students to practice the MLA and APA citation methods?
notka56 [123]

Answer:

Citing or documenting the sources used in your research serves three purposes:

It gives proper credit to the authors of the words or ideas that you incorporated into your paper.

It allows those who are reading your work to locate your sources, in order to learn more about the ideas that you include in your paper.

5 0
3 years ago
Help to how to write pseudo code to insert a new node to Binary Search Tree. Using C++.
dimulka [17.4K]

Answer:

Let the function be Node* ins(Node *root,int k)

if root node is NULL then return new node with data equal to k.

If the k <root->data

root->left=ins(root->left,k);

else if k >root->data

root->right =ins(root->right,k);

At last return root.

Explanation:

Node is always inserted at the at the leaf node.We will search k in the tree if we hit a the leaf node the new node is inserted as the child of the leaf node.

4 0
3 years ago
32.
qaws [65]

Answer:

a

Explanation:

hackers access your system unauthorized

5 0
3 years ago
The main purpose of a honeypot is Select one:
masya89 [10]

Answer:

d. To help security professionals better understand and protect against threats to the system

Explanation:

The main purpose of a honeypot is to attract potential hackers and allow them to have access to a network system that is not the actual live network with close monitoring. This is done so as to learn and understand the intentions of the hacker and how they execute an attack. With this knowledge security professional are in a better position to deal with potential threats and keep the network secure.

4 0
3 years ago
A(n) ____________ is a private data network that creates secure connections over regular internet lines.
Setler79 [48]
VPN is the correct answer
5 0
4 years ago
Other questions:
  • a ____ consists of wires connecting the cpu and other parts of the computer. The _____ transfers data between CPU and memory uni
    6·1 answer
  • High productivity will typically get you positive attention and feedback when you are on a job.
    7·1 answer
  • Which cost of purchasing a franchise would you still have if you start your own business​
    12·1 answer
  • Write a method for the Customer class that that will return a string representing a bill notice when passed a double value repre
    14·1 answer
  • Which of the following is used to describe the information used in
    12·1 answer
  • Who is the father of computer?​
    6·1 answer
  • Which media vehicle uses the Dreamweaver software for its design? A(n) "blank" uses the Dreamweaver software for its design.
    8·1 answer
  • Did brainly.com go down today? i coudlnt get in it
    15·2 answers
  • PLEASE HELPPPPP ASAP, 50 POINT'S + BRAINLIEST
    14·1 answer
  • Tina reported a safety hazard at her workplace to OSHA. Representatives from OSHA came to her work and inspected the issue, then
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!