CountEvensInArray

CountEvensInArray - } for (int i = 0; i <...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
import java.util.Scanner; i public class CountEvensInArray { public static void main (String [] args) { int[] numArray = new int[10]; int count = 0; i Scanner in = new Scanner(System.in); S for (int i = 0; i < numArray.length; i++) { System.out.print ("Enter number " + i + " : "); numArray[i] = in.nextInt();
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: } for (int i = 0; i &lt; numArray.length; i++) if (even (numArray[i])) count++; System.out.println (&quot;There are &quot; + count + &quot; even numbers&quot;); } private static boolean even (int number) { if (number % 2 == 0) return true; else return false; } }...
View Full Document

This note was uploaded on 06/07/2010 for the course CS 201 taught by Professor Staff during the Spring '08 term at Iona.

Ask a homework question - tutors are online