Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > Java Basics
|
Java Basics General beginning Java language questions that don't fit in one of the more specific forums. Please specify what version.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Java Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 8th, 2014, 08:51 AM
Registered User
 
Join Date: Dec 2014
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default UnknownFormatConversionException

Hi... I have a homework on studentPoll code. It doesn't work and I always get UnknownFormatConversionException. Any ideas? THNX


public class studentPoll {
{
public static void main( String[]args)
{

int[] responses = { 1, 2 , 5, 4, 3 , 5, 2, 1 , 3, 3, 1, 4, 3, 3, 3,
2, 3, 3, 2, 14 };


int [ ] frequency = new int [ 6 ];

for ( int answer = 0; answer <responses.length; answer++ )
{
try
{
++ frequency [responses[answer] ];
}
catch ( ArrayIndexOutOfBoundsException e )
{
System.out.println( e );
System.out.printf( "responses[ %d] = %d\n\n",answer, responses[answer] );
}
}
System.out.printf( " %s%1 0s\n", "Rating", " Frequency " );


for ( int rating = 1; rating < frequency.length; rating ++ )
System.out.printf( "% 6d%10 d\n" , rating, frequency[ rating ] ) ;
}
}









Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.