A good answer might be:

The completed program is given below.

Complete Program

Here is the complete program that adds up even and odd integers from zero the limit N specified by the user:

import java.io.*;

// User enters a value N
// Add up odd integers,  even  integers, and all integers 0 to N
//
class addUpIntegers
{
  public static void main (String[] args ) throws IOException
  {
    BufferedReader userin = new BufferedReader (new InputStreamReader(System.in));
    String inputData;
    int    N, sumAll = 0, sumEven = 0, sumOdd = 0;

    System.out.println( "Enter limit value:" );
    inputData = userin.readLine();
    N         = Integer.parseInt( inputData );

    int count = 0 ;
    while (  count <= N )    
    {
      sumAll = sumAll + count ;
      
      if ( count % 2 == 0  )
        sumEven = sumEven + count ;

      else
        sumOdd  = sumOdd  + count ;

      count = count + 1 ;
    }

    System.out.print  ( "Sum of all : " + sumAll  );
    System.out.print  ( "\tSum of even: " + sumEven );
    System.out.println( "\tSum of odd : " + sumOdd  );
  }
}

It would be odd if you did not copy and paste this program to NotePad and run it. An even better idea would be to pretend you had not seen it, and to try to create it from scratch.

QUESTION 5:

Which is larger: the sum of evens or the sum of odds? Does the answer to this question change if N is even or odd?