I need solution write a program the reads string from the user then count the nu
ID: 3636094 • Letter: I
Question
I need solutionwrite a program the reads string from the user then count the number of 't' characters and 'p' characters in a given string .
enter "yes" if you want to continue reading a string , otherwise enter "no"
my answer :
import java.util.*;
/**........................*/
Scanner input =new Scanner(System.in);
int countt = 0, countp = 0 ;
String s , s1;
System.out.println("Enter the String :");
s=input.nextLine();
for(int j=1;j<=s.length();j++)
{
for(int i=0;i<s.length();i++)
{
if(s.charAt(i)=='t')
countt++;
if(s.charAt(i)=='p')
countp++;
}//for2
System.out.println("Enter the String :");
s=input.nextLine();
}//for1
System.out.println("number of t characters :"+countt+" "+"number of p characters:"+countp);
}//main
}//class