![jngonzo1226](/avatars/18809.jpg)
jngonzo1226
09.03.2020 •
Computers and Technology
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.
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. n is different than N.
Ex: If the input is: n Nobody,
the output is: 0
Your program must define and call the following function that returns the number of times the input character appears in the input string.
int CountCharacters(char userChar, string userString)
Solved
Show answers
More tips
- F Family and Home How to Choose a Name for Your Baby?...
- B Business and Finance How to Open an Online Store? A Detailed Guide for Beginners...
- W Work and Career How to Write a Resume That Catches the Employer s Attention?...
- C Computers and Internet Е-head: How it Simplifies Life for Users?...
- F Family and Home How to Choose the Best Diapers for Your Baby?...
- F Family and Home Parquet or laminate, which is better?...
- L Leisure and Entertainment How to Properly Wind Fishing Line onto a Reel?...
- L Leisure and Entertainment How to Make a Paper Boat in Simple Steps...
- T Travel and tourism Maldives Adventures: What is the Best Season to Visit the Luxurious Beaches?...
- H Health and Medicine Kinesiology: What is it and How Does it Work?...
Answers on questions: Computers and Technology
- C Computers and Technology 1) What is an Electronic point of sale? [2]Answers Here...
- C Computers and Technology What is a post? A. A type of computer software B. A magazine on the internet C. An online message D. The audience of a blog...
- C Computers and Technology Select all key ethical issues in data mining. -People may not be aware that their personal information is being gathered. -People have not consented to the collection or...
- B Business How are tangible and intangible assets normally presented on the balance sheet? a.they are listed separately as property, plant, and equipment and intangible assets. b.both...
- P Physics Starting from rest, a 68.0 kg woman jumps down to the floor from a height of 0.790 m, and immediately jumps back up into the air. while she is in contact with the ground...
- B Business The advantage to departmentalizing by the function performed is group of answer choices a. increased accountability for product performance under a single manager. b.obtaining...
- H Health At 6 months, annabelle dropped her rattle in a fairly rigid way. by 12 months, she tossed objects down the basement stairs, bounced them off walls, and threw them in the...
- C Chemistry Given the values of so given below in j/mol k and the values of δhfo given in kj/mol, calculate the value of δgo in kj for the combustion of 1 mole of propane to form carbon...
- S Social Studies Susan s brother was recently hospitalized when he was found dancing wildly in the center of a public fountain. her brother had not slept in five days before being hospitalized....
- S Social Studies Avoter has seen his income increase by 3% over the past four years. he is encouraged that unemployment is down and the price of gas has remained relatively low. on election...
Ответ:
The program written in Java is given in the explanation section
Explanation:
public class num9 {
//Defining the method CountCharacters()
public static int CountCharacters(char userChar, String userString){
int c = userString.length();
int count=0;
for(int i=0; i<c; i++){
if(userString.charAt(i)==userChar){
count++;
}
}
return count;
}
//Main method begins here
public static void main(String[] args) {
char n ='n';
String word = "Monday";
//Calling the method CountCharacters()
System.out.println(CountCharacters(n,word));
}
}
Ответ:
codingthe algo- rithm
Explanation:
hope I helped