-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprg3.java
More file actions
40 lines (28 loc) · 764 Bytes
/
prg3.java
File metadata and controls
40 lines (28 loc) · 764 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
28
29
30
31
32
33
34
35
36
37
38
39
40
import java.util.*;
class prg3
{
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
String Str1 = in.nextLine();
int[] a = new int[30];
int max = 0;
for(int i=0;i<30;i++)
{
a[i] = 0;
}
for( int i =0 ; i < Str1.length() ; i++)
{
char c1 = Str1.charAt(i);
a[c1 - 97]++;
}
for(int i =0; i < 30 ; i++)
{
if(a[i] > a[max])
{
max = i;
}
}
System.out.println((char)(max + 97) + " is highest occurence " + a[max] );
}
}