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
denis23 [38]
4 years ago
10

java methods Write a program whose input is a character and a string, and whose output indicates the number of times the charact

er appears in the string.

Computers and Technology
1 answer:
AfilCa [17]4 years ago
5 0

Answer:

Here is the JAVA program:

import java.util.Scanner; // for taking input from user

//class to count number of times a character appears in the string

public class CharacterCounter

//method which returns number of times a character appear in string

{ public static int CountCharacter(String userString, char character)

   {  

       int counter = 0;   //stores the no of times character appears in string

for (int i=0; i<userString.length(); i++) //loop moves through entire string

       { // if character matches the character in the string

           if (userString.charAt(i) == character)

           counter++;  // adds one to the character counter variable

       }  

       return counter;     } // returns no of time character is found in string

public static void main(String[] args) {

    Scanner scanner = new Scanner(System. in);//takes input from user

    String string;

    char character;

       System.out.println("Enter a string"); //prompts user to enter a string

       string = scanner.nextLine(); //scans the input string

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

       // prompts user to enter character

       character = scanner.next().charAt(0); //scans and reads the character

       System.out.println("number of times character "+character + " appears in the string " + string +": " + CountCharacter(string, character));  }  }

// calls CountCharacter method to output no of times a character appears in the input string

Explanation:

The method CountCharacter() has a loop in which the variable i works as an index which moves through each character of the string and if the character of the string in i matches the character which is to be found in the string then the value of counter variable increments by 1. This means that counter variable keeps counting the number of time the character appears in the string. The loop breaks when value of i exceeds the length of the string which means that the i reaches the end of the string and has searched the entire string for the specified character. In the end the count variable returns the number of time character appeared in the string. The main() function takes as input from the user, a string and a character to be searched for in the string. It then calls CountCharacter() function to find the number of times that input character appears in the input string and displays it on the output screen.

The program along with its output is attached as a screenshot.

You might be interested in
Were can i watch unexpected free season 3
Vesna [10]

Answer:

Netflix

Explanation:

3 0
3 years ago
A(n) _________ is any system resource that is placed onto a functional system but has no normal use for that system. If it attra
Kisachek [45]

Answer:

Honeytoken

Explanation:

Honeytokens (aka honey traps or honeypots) may be described as bogus or dummy IT resources which are created or placed in a system or network for the sole purpose of attracting the attention of cyber-criminals and being attacked. These might be servers, applications, complete systems or datasets which are placed online (via the public internet, or a public-facing gateway to a private network), in order to attract cyber-attackers.

Honeytokens may be specifically defined as pieces of data which on the surface look attractive to potential attackers, but actually have no real value – at least, not to the attacker. For the owners of the tokens (i.e. the people who set the trap), they can be of great value, as they contain digital information which is monitored as an indicator of tampering or digital theft.

8 0
3 years ago
What is aperture priority mode? When might you use this mode on a camera? What is depth of field? How can you adjust the depth o
raketka [301]

Answer:

Please check explanation

Explanation:

We abbreviate aperture priority by A or Av( which is used for aperture value) on the camera mode call up, which is an adjustment on some of the cameras which leverage the user to adjust the certain value of the aperture or the f-number as meanwhile the camera adjust the speed of the shutter ensuring it matches it, and which results in a good exposure depending on the condition of the light  as being measured via the light meter. And this is not the same as the manual mode, in which the user is compelled to make the decision for both the values, the priority of the shutter, the location the user selects the shutter speed while the camera picks up the correct aperture, as well as the program state, where camera picks each of them.

So the first two questions are answered. Let's see the third, the depth of the field.  It is the distance from the nearest to the furthest objects which provides an image being selected for being at the focus in a camera.

Hence the depth of the field means the range of the sharp focus in a certain photograph. And while you shoot with the help of the larger camera like the DSLR, you will be able to adjust the depth through the adjustment of the aperture of the lens. The aperture is nothing else but the opening within the lens which manages the amount of the light that is permitted via the lens.

Now come to the fifth question. The shutter speed and the aperture are being related directly. It improves the aperture (by a stop). And each of them comes up with the very best exposure through the permitted weight of light.

And both of them are related to each other in an inverse proportion. And both of them must be balanced for ensuring that the image is not being exposed or less exposed to the permitted light. And when the aperture is increased the shutter speed increased for balancing it as well as vice versa.

Landscape mode:

It is the kind of page orientation that prints out the picture in a horizontal manner rather than in a vertical manner. And it is being commonly used for printing the charts or various other types of pictures as well as the text which might not adjust properly with the page that is aligned vertically.

Consider the High Nikon DSLR. You need to hold down the "MODE" as meanwhile the rear control (dial)  is turned unless you view "A" over the LCD top. And your FCD then sets the aperture. And in almost all Canon SLRs as an example: You need to turn to "Av" your mode dial.

The results of these adjustments are certainly good.

And the shutter speed is being measured by the unit of time and ranges in less than fractions of one second. And as we say that the shutter speed is "5000", it means its 1/30000 th of a  minute. And the shutter speed which is of one second or more in length is being marked as a'. One example is 16'.

How we measure aperture. And what it means:

It is being measured with the help of the f-stop scale. And on the digital camera, you will find 'f/' which is being followed by an integer. And this f-number indicates the wideness of the aperture. As well as the size does affect the exposure as well as the field depth of the resultant image.

Now come to why we should learn to control the shutter speed and the aperture.

You should know that by selecting the shutter speed you permit yourself to freeze or otherwise blur motion, and sometimes you would like to do the first one or the second one. And the aperture permits you to select the field depth to either blur the background or make it sharper.

Thus, now you have an idea of each of the modes, and their merits. And if you will ask the best one, he will be up with the aperture priority or with auto ISO and full manual. If you are up with some specific requirements, then you should have a full manual mode in automatic mode, and that will be quite handy. You certainly need to learn by heart how to make use of the full manual, as it will improve your understanding of the photography, however, the semi-automatic mode is certainly your best friend.

And yes, as well as its a very great feeling. Its certainly quite hard to take the photographs of still objects while you are riding.

Some of the things that make it hard to take the action photographs are like the object, or the animal can move as well as you need to set the shutter speed as well as the aperture speed quite swiftly. Also, you need to focus your camera for ensuring a very good picture and ensure its not blurry or like the picture is out of the focus.

In night photography, the camera might shake because of the very low ambient brightness, the camera might move for very slow shutter speed. Various other challenges are the improper focus, white balances, less exposure, etc,

That solves all the questions asked.

3 0
3 years ago
Could you describe in 3 lines what an API is?
Brilliant_brown [7]

An API is in computer programming. So it is an application programming interface is a set of several subroutine definitions. Also consists of Communication protocols and tools for you to build software.

Also known by its full names, Application Programming Interface. I was just going to ask it myself actually.

I hope this helps and good question?

8 0
4 years ago
The ________ is the main switch station for memory; if the right and left areas are destroyed, the result is widespread amnesia.
Scorpion4ik [409]

Answer:

The answer is hippocampus.

Explanation:

The ___hippocampus._____ is the main switch station for memory; if the right and left areas are destroyed, the result is widespread amnesia. The __hippocampus.______ is the main switch station for memory; if the right and left areas are destroyed, the result is widespread amnesia.

4 0
3 years ago
Other questions:
  • The mouse and keyboard are also sometimes called
    5·1 answer
  • What is also known as a visual aid in a presentation?
    14·2 answers
  • A list of the slides in a presentation is found here.
    7·2 answers
  • Ergonomia este știința care studiază ....
    6·1 answer
  • Which of the file names below follows standard file naming convention?
    12·2 answers
  • What is the default view in a Word document?
    10·2 answers
  • USB flash drives are small portable units that are used to ____________files.
    5·2 answers
  • Create a Python program to solve a simple payroll calculation. Calculate the amount of pay, given hours worked, and hourly rate.
    12·1 answer
  • What are some example of popular music for teenagers
    8·2 answers
  • How do you take a picture on an apple computers
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!