Results 1 to 2 of 2
  1. #1
    Slice28 is offline Member
    Join Date
    Mar 2012
    Posts
    3
    Rep Power
    0

    Question Help with input stream

    My goal is to create a program that reads a stream of integers and to determine whether each integer is even or odd. Each even number should be added to an even accumulator and each odd number should be added to an odd accumulator. The program should print out the amount of even numbers entered as well as the number of odd numbers entered. The problem that I am having is with the input stream. I can only get the program to recognize the first number entered and determine whether even or odd. I don't know how to make the program determine whether each number entered is even or odd. For example if the user entered 2 4 45 the only thing I can get the program to determine is whether the first number entered (2) is even or odd. Help please.

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,589
    Rep Power
    23

    Default Re: Help with input stream

    whether each number entered is even or odd.
    Use the modulus operator with 2

    You will have to post the code for anyone to see what the problem is with the reading of numbers.

Similar Threads

  1. Unexpected end of ZLIB input stream
    By tx00824 in forum Java Applets
    Replies: 0
    Last Post: 12-30-2011, 10:58 PM
  2. Should this input stream be closed?
    By barock in forum Advanced Java
    Replies: 8
    Last Post: 06-10-2011, 07:11 PM
  3. Readline from an input stream and nothing more.
    By couling in forum Advanced Java
    Replies: 19
    Last Post: 05-27-2011, 09:20 PM
  4. Input Stream as an Object?
    By sehudson in forum New To Java
    Replies: 1
    Last Post: 03-12-2011, 12:37 AM
  5. Input stream error
    By Johnny68 in forum New To Java
    Replies: 10
    Last Post: 08-05-2010, 06:20 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •