Answer:
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));
}
}