Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class test1 {
- public static void main(String[] str) {
- String word = "aabbccc";
- int acount = 0;
- int bcount = 0;
- int ccount = 0;
- String highest = "";
- for (int i = 0; i < word.length(); i++){
- if (word.charAt(i) == 'a')
- acount++;
- else if (word.charAt(i) == 'b')
- bcount++;
- else if (word.charAt(i) == 'c')
- ccount++;
- }
- if (acount > bcount && bcount > ccount)
- highest = "acount";
- else if (bcount > acount && acount > ccount)
- highest = "bcount";
- else if (ccount > acount && acount > bcount)
- highest = "ccount";
- System.out.println(highest);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement