All pastes #183430 Raw Edit

Anonymous

public java v1 · immutable
#183430 ·published 2006-09-26 22:28 UTC
rendered paste body
    	    for (int i = 1; i <= numberOfEntries; i++)    	    {    	    	/*    	         * Catch any and all errors (type mis-match errors) that way we don't    	         * crash the user of this program :-)    	         */    	    	try    	    	{    	    		/*    	    		 * 	Prompt the user to enter test score "i"    	    	 	*/    	    		System.out.print("Enter score " + i + ": ");			        	    		/*    	    		 * Grab the Integer    	    		 */    	    		testScore = sc.nextInt();    	    	}    	    	catch(InputMismatchException e)    	    	{    	    		/*    	    		 * Discard the invalid data entry    	    		 */    	    		sc.next();    	    		    	    		/*    	    		 * Notify the user of their mistake    	    		 */    	    		System.out.println("Invalid entry, not counted");    	    		    	    		/*    	    		 * Jump back into the loop    	    		 */    	    		continue;    	    	}    	    }