Question: 4 . 1 6 LAB: Count characters exactly 1 . Exifthe ingut is: Manday the output is: 1 n Exlfthe inputiz: = Today 1 a

4.16 LAB: Count characters exactly 1.
Exifthe ingut is:
Manday
the output is:
1 n
Exlfthe inputiz:
= Today 1a Monday
the outgut is:
\[
0=x^{\prime} a
\]
Exlfthe inputiz:
a It'a a aunny day
the output is:
\[
2\mathrm{n}^{\prime}\mathrm{a}
\]
Case mattars.
Exlf the ingut is:
D Nohody
the outgut is:
\[
0\mathrm{n}\cdot \mathrm{a}
\]
nis dfferant than N.
0.10
LabProgram.java
Load default template...
```
Import java.ut:1l.Scarner;
public class Laberogran {
public statlic vold rain(String[] args)[
Scanner Sc = now Scanner(Systen.In);
// Proept and read the character Enput
Char ch = sc_noxt()-charat(B); // heud the first chanacter
sc.nertline(); // Clear the newline chanacter
// Proept and read the streling inpurt
String str = sc.nextLine();
Int count =0;
// Count occurrences of the chanacter in the string
for (Int i =0; i str.length(); i++}(
if (str.charAt(1)== ch){
count++;
}
)
// Output the result with proper pluralization
}
System_out.print1n(count +=+ ch +((count =-1)?" : "s")};
)
```
4 . 1 6 LAB: Count characters exactly 1 . Exifthe

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!