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
mylen [45]
3 years ago
8

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: n appears this many times: 1 Ex: If the input is: z Today is Monday the output is: z appears this many times: 0 Ex: If the input is: n It's a sunny day the output is: n appears this many times: 2 Case matters. Ex: If the input is: n Nobody the output is: n appears this many times: 0
Computers and Technology
1 answer:
Svet_ta [14]3 years ago
5 0

Answer:

import java.util.Scanner;

public class NumberOfOccurences {

public static void main(String[] args) {

 // Create an object of the Scanner class to allow for user inputs

 Scanner input = new Scanner(System.in);

 // Prompt user to enter text

 System.out.println("Please enter the phrase");

 // Store text in a variable

 String phrase = input.nextLine();

 // Prompt user to enter character to be checked

 System.out.println("Please enter the character to check");

 // Store character in a char variable

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

 // Create and initialize a variable count to zero

 // count will hold the number of occurrences of the character in the phrase

 int count = 0;

 // Loop through each of the character in the string text

 // At every cycle of the loop, compare the character of the string

 // with the character to be checked.

 // If they match, count is incremented

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

  if (phrase.charAt(i) == character) {

   count++;

  }

 }

 // Print out the number of occurrences due to count

 System.out.println(character + " appears this many times " + count);

}

}

Explanation:

The source code file has been attached to this response and has been saved as "NumberOfOccurrences.java". Please download the file and go through the code including the comment. Pay attention to the comments for readability and understandability.

Hope this helps!

Download java
You might be interested in
If an OS is using paging with offsets needing 12 bits, give the offset (in decimal or hexadecimal) to: the third word on a page
Mariulka [41]

Answer:

Explanation:

If an OS is using paging with offsets needing 12 bits, give the offset (in decimal or hexadecimal) to: the third word on a page the last word on a page.

7 0
3 years ago
Which best describes a career that would rely on both and employer and the federal government for funding? Electro-Mechanical Te
Dmitrij [34]

Answer:

<u>University Research Professor</u>

Explanation:

A university Professor can identify a research in his/her area of study and prepare a proposal for funding.This could be a research that will impact the nation thus a proposal could be presented to the federal government for funding. Additionally, the Professor can present the same proposal to the university research department to request funding of the project.The University which employed the Professor will now fund that project research and make it public to members of the community about the research that the University is undertaking with the professor as the leader of the research.

8 0
3 years ago
Daisy, an HR executive at Matrix-Solutions, was given the responsibility to conduct induction training for the newly hired emplo
sasho [114]

Answer:

The answer is Presentation Software.

Explanation:

The application that best suits her purpose is a Presentation Software. Such as: powerpoint, google presentations, keynote,  OpenOffice Impress, Media Shout, Harvard Graphics, Adobe Persuasion.

These are excellent tools for Daisy's purpose.

8 0
3 years ago
Why does a layer 3 device perform the anding process on a destination ip address and subnet mask?
mafiozo [28]
To get the network number and node number of the destination machine. The subnet mask is usually called the NETwork MASK, so anding it with the address gives you the network number. Using the not logical operator on the netmask then protects the node bits in a second and operation.

address & netmask = network number
address & not( netmask ) = node number

The not operator essentially just flips the bits of it's argument.
8 0
3 years ago
Which type of virtualization do storage area networks typically use?
cupoosta [38]

They use the SCSI protocol for communication between servers.

haha im a computer geek.Good luck!

4 0
3 years ago
Read 2 more answers
Other questions:
  • A prime number is a number that is only evenly divisble by itself and 1.
    12·1 answer
  • A customer in a store is purchasing five items. Design a program that asks for the price of each item, and then displays the sub
    11·1 answer
  • The difference between the various networks is the ______ of the coverage.
    11·2 answers
  • What is a service-oriented architecture? Group of answer choices A business-driven enterprise architecture that supports integra
    13·1 answer
  • Help please appreciate it
    15·1 answer
  • Hurry answerrrrrrr pleaseee
    11·2 answers
  • A filter is limited to extracting data from a single table. <br> a. True <br> b. False
    9·1 answer
  • I have a question. This question will probably be deleted, but why do moderators keep deleting my answers when they are legitima
    13·1 answer
  • Where are super computer mainly used​
    13·2 answers
  • Represent the measuring unit ofcomputer un terms of fration of second​
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!