Tpotify.java
/**
     * The main method does input and output and call another two methods to calculate the index
     * and find the most played genre.
     *
     * @param args unused
     */
The main method does input and output and call another two methods to calculate the index
and find the most played genre.

@param args unused
The main method does input and output and call another two methods to calculate the index and find the most played genre . @param args unused
public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        char[] genres = {'C', 'E', 'H', 'J', 'P'};   
        int[] summaryStorage = new int[genres.length];
        int userCount = scan.nextInt();
        int summaryMaxIndex = 0;
        for (int i = 0; i < userCount; ++i) {
            String userName = scan.next();
            String userGenre = scan.next();
            int[] userStorage = new int[genres.length];
            int userMaxIndex = 0;
            for (int j = 0; j < userGenre.length(); ++j) {
                ++userStorage[indexOf(genres, userGenre.charAt(j))];
                ++summaryStorage[indexOf(genres, userGenre.charAt(j))];
            }
            userMaxIndex = findMaximumIndex(userStorage);
            System.out.println(userName + ": " + genres[userMaxIndex]);
        }
        summaryMaxIndex = findMaximumIndex(summaryStorage);
        System.out.println("Summary: " + genres[summaryMaxIndex]);
        scan.close();
    }
public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; char [ ] genres = { 'C' , 'E' , 'H' , 'J' , 'P' } ; int [ ] summaryStorage = new int [ genres . length ] ; int userCount = scan . nextInt ( ) ; int summaryMaxIndex = 0 ; for ( int i = 0 ; i < userCount ; ++ i ) { String userName = scan . next ( ) ; String userGenre = scan . next ( ) ; int [ ] userStorage = new int [ genres . length ] ; int userMaxIndex = 0 ; for ( int j = 0 ; j < userGenre . length ( ) ; ++ j ) { ++ userStorage [ indexOf ( genres , userGenre . charAt ( j ) ) ] ; ++ summaryStorage [ indexOf ( genres , userGenre . charAt ( j ) ) ] ; } userMaxIndex = findMaximumIndex ( userStorage ) ; System . out . println ( userName + ": " + genres [ userMaxIndex ] ) ; } summaryMaxIndex = findMaximumIndex ( summaryStorage ) ; System . out . println ( "Summary: " + genres [ summaryMaxIndex ] ) ; scan . close ( ) ; }
The main method does input and output and call another two methods to calculate the index
 and find the most played genre.
The main method does input and output and call another two methods to calculate the index and find the most played genre .
// Do not modify, may fail test
