JAVA LAB: Count characters
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. The output should include the input character and use the plural form, 's', if the number of times the character appears is not exactly 1.
Ex: If the input is:
n Monday
the output is:
1 n
Ex: If the input is:
z Today is Monday
the output is:
0 z's
Ex: If the input is:
n It's a sunny day
the output is:
2 n's
Case matters.
Ex: If the input is:
n Nobody
the output is:
0 n's
'n' is different than 'N'.
LabProgram.java
import java.util.Scanner;
public class LabProgram {
public static void main(String[] args) {
/* Type your code here. */
}
}
16.3 LAB: Count characters
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. The output should include the input character and use the plural form, 's', if the number of times the character appears is not exactly 1.
Ex: If the input is:
Aepuow u
the output is:
1 n
Ex: If the input is:
z Today is Monday
the output is:
0 z's
Ex: If the input is:
n It's a sunny day
the output is:
2 n's
Case matters. Ex: If the input is:
n Nobody
the output is:
0 n's
'n' is different than 'N'.
LAB ACTIVITY 16.3.1: LAB: Count characters
0 / 10
LabProgram.java
Load default template...
import java.util.Scanner;
public class LabProgram {
public static void main(String[] args) {
// Type your code here.
}
}