Java - Using a method, how do I "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. Your program must define and call the following method that returns the number of times the input character appears in the input string. public static int countCharacters(char userChar, String userString)"
So far I have the following:
import java.util.Scanner;
public class LabProgram {
public static int countCharacters(char userChar, String userString)
{
// Create an object of the Scanner class to allow for user inputs
Scanner input = new Scanner(System.in);
// Store text in a variable
userString = input.nextLine();
// Store character in a char variable
userChar = 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 < userString.length(); i++) {
if (userString.charAt(i) == userChar) {
count++;
}
}
// Print out the number of occurrences due to count
System.out.println(userChar + " appears this many times " + count);
}
public static void main(String[] args) {
countCharacters(userChar, userString);
}
}
and my error is that I can't get it to run on main / I don't know where everything goes. I found the code somewhere and I've tried modifying it.
Answer:Java - Using a method, how do I "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. Y"
"Crowdsourcing" is the correct answer for the above question.
Explanation:
Crowdsourcing is a term from which any organization advertises the thinks or can get the ideas or solutions for any particular problem.
It is a term that refers to the problem to the number of solvers to achieve the result correct and frequent.
For example, If anyone wants to prepare the two websites. Then he assigns the works to the number of people and the works done faster with the help of this.
The above question states that some websites can be successful with the help of the type of work. They are successful with the help of crowdsourced work. Because it saves time. So the answer is Crowdsourcing.
If you send a photo to a person, you need to be very careful not to send something that can give your information away, this includes but it not limited to Pictures of your town, Pictures of You, Pictures of Friends, Pictures of Family, etc.