-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfrequency.java
More file actions
27 lines (27 loc) · 705 Bytes
/
Copy pathfrequency.java
File metadata and controls
27 lines (27 loc) · 705 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import java.util.*;
class frequency
{
public static void main(String args[])
{
System.out.println("enter the string");
Scanner obj = new Scanner(System.in);
String n = obj.nextLine();
int y = n.length();
y--;
int count = 0;
char x[] = n.toCharArray();
int i,flag=0;
System.out.println("enter the character to count the frequecy count");
char s = obj.next().charAt(0);
for(i=0;i<=y;i++)
if(x[i] == s)
{
flag=1;
count = count+1;
}
if(flag==1)
System.out.println("the frequency of time the character repeat is "+count);
else
System.out.println("entered the character to count the frequecy count is not in the string");
}
}