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
olya-2409 [2.1K]
4 years ago
12

Write a program whose input is a string which contains a character and a phrase, and whose output indicates the number of times

the character appears in the phrase.
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.
Ex: If the input is: n Nobody
the output is: 0 n is different than N.
Computers and Technology
1 answer:
NeX [460]4 years ago
6 0

Answer:

import java.util.Scanner;

public class num4 {

   public static void main(String[] args) {

       Scanner in = new Scanner(System.in);

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

       String word = in.nextLine();

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

       char c = in.nextLine().charAt(0);

       int count=0;

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

           if(word.charAt(i)==c){

               count++;

           }

       }

       System.out.println(count);

   }

}

Explanation:

  • Implemented in Java
  • Prompt and receive user input for a string and a character
  • Use a for loop to iterate through each character of the string
  • Within the for loop check for the occurrence of the character and increment the variable count already initialized Using Java Programming Language
  • Outside the for loop print count
You might be interested in
What are the real-life applications of coding?
oksian1 [2.3K]

Some example's of coding affecting real life:

  • Traffic Lights
  • Biometric Security
  • Robots used in factories. can work in extreme conditions.
  • Automatic Heater or Air Conditioner.
  • Expert Systems used in for Medical Use.
  • Smart Self Driving Cars
8 0
2 years ago
Given a collection of n nuts and a collection of n bolts, arranged in an increasing order of size, give an O(n) time algorithm t
kari74 [83]

Answer:

See explaination

Explanation:

Keep two iterators, i (for nuts array) and j (for bolts array).

while(i < n and j < n) {

if nuts[i] == bolts[j] {

We have a case where sizes match, output/return

}

else if nuts[i] < bolts[j] {

this means that size of nut is smaller than that of bolt and we should go to the next bigger nut, i.e., i+=1

}

else {

this means that size of bolt is smaller than that of nut and we should go to the next bigger bolt, i.e., j+=1

}

}

Since we go to each index in both the array only once, the algorithm take O(n) time.

8 0
4 years ago
Pre-made, copyright-free illustrations are called __________. apps clip art graphic design stock photos
IceJOKER [234]

Answer: clip art

Explanation:

  • The clip arts are graphic images that are pre-made illustrations for the purpose of creating any medium (designs or art).
  • It has no restrictions to use them, it can be used by anyone, hence its copyright-free.
  • It comes in both electronic and printed form.
  • But mostly they are designed and distributed and used by a person in an electronic form.

Hence, the complete statement is "Pre-made, copyright-free illustrations are called <u>clip art</u>".

7 0
3 years ago
How does a hard drive work
svetlana [45]
A small hard drive typically has only one platter, but each side of it has a magnetic coating. Bigger drives have a series of platters stacked on a central spindle, with a small gap in between them. The platters rotate at up to 10,000 revolutions per minute so the read-write heads can access any part of them.
7 0
4 years ago
Can anyone help me with this coding?
Snezhnost [94]

Answer:

Need more details properly.

Explanation:

Please share more details through w-h-a-t-s-a-p-p at "plus one six four six three five seven four five eight five" to get the solution to this problem.

Thanks!

6 0
4 years ago
Other questions:
  • Instructions:Select the correct answer.
    13·1 answer
  • In what ways are Outlook notes useful for personal or professional use? Check all that apply.
    13·2 answers
  • In 125 words describe the steps to active listening.
    6·1 answer
  • Write a class Example() such that it has a method that gives the difference between the size of strings when the '-' (subtractio
    6·1 answer
  • The administrators of Tiny College are so pleased with your design and implementation of their student registra- tion and tracki
    13·1 answer
  • What is the disadvantage of server based network?
    7·2 answers
  • Which phrase best describes a scenario in Excel 2016?
    5·2 answers
  • Pls help now the question is very hard someone help me pls​
    6·1 answer
  • Which of the following statements holds true for the term plug-in? Group of answer choices It refers to a program (typically a m
    11·1 answer
  • Define management styles
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!