Advertisement
Guest User

Untitled

a guest
Jun 19th, 2013
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.63 KB | None | 0 0
  1. public class test1 {
  2.  
  3.  
  4.    
  5.     public static void main(String[] str) {
  6.         String word = "aabbccc";
  7.         int acount = 0;
  8.         int bcount = 0;
  9.         int ccount = 0;
  10.         String highest = "";
  11.         for (int i = 0; i < word.length(); i++){
  12.             if (word.charAt(i) == 'a')
  13.                 acount++;
  14.             else if (word.charAt(i) == 'b')
  15.                 bcount++;
  16.             else if (word.charAt(i) == 'c')
  17.                 ccount++;
  18.         }
  19.         if (acount > bcount && bcount > ccount)
  20.             highest = "acount";
  21.         else if (bcount > acount && acount > ccount)
  22.             highest = "bcount";
  23.         else if (ccount > acount && acount > bcount)
  24.             highest = "ccount";
  25.            
  26.         System.out.println(highest);
  27.        
  28.  
  29.  
  30.     }
  31.  
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement