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

    Question Need help with assignment

    I cant wrap my head around this assignment. All I have accomplished to this point is to determine wether the integer entered is even or odd. Can someone please break it down for me how I would go about this. Here is the assignment:

    Write a program that reads in a set of integer numbers. While reading the input stream, the program should determine if each item integer item in the input stream is an odd or even number. If the number is odd it should be added to an odd number accumulator, if the number is even it should be added to an even number accumulator. The program should then print the total for the number of even numbers entered and the total for the number of odd numbers entered. The program should also keep count of the number of odd numbers in the input stream and the count of the number of even numbers in the input stream. The program should additionally print out the count of the odd numbers entered and the count for even numbers even. Format the numeric output. Place the appropriate labels in the output to identify the information.

  2. #2
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    7

    Default Re: Need help with assignment

    Ok, so whats the difference between an even and an odd number? How do you as a human know whether a number is even or odd?

    Once you answer that question, how might you reproduce the same even/odd test in code?

  3. #3
    Slice28 is offline Member
    Join Date
    Mar 2012
    Posts
    3
    Rep Power
    0

    Default Re: Need help with assignment

    I should have been more specific. Im not having trouble determining wether the number is even or odd. The issue Im having is adding the numbers to an accumulator. I dont know how to make the program determine how many values we're inputed. Confused by the input stream.

  4. #4
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    7

    Default Re: Need help with assignment

    Well, you could count the numbers as they are added, or if your accumulator is based on an array or list of some type, you have methods that can be used to get the current size of the list!

Similar Threads

  1. assignment help :L
    By Mike09lfc in forum New To Java
    Replies: 2
    Last Post: 12-03-2011, 02:38 AM
  2. Assignment Help
    By Albany in forum New To Java
    Replies: 6
    Last Post: 12-02-2011, 11:39 PM
  3. I need help with an assignment
    By newarcher in forum New To Java
    Replies: 12
    Last Post: 09-08-2011, 01:09 PM
  4. assignment help
    By esallender in forum New To Java
    Replies: 4
    Last Post: 10-25-2010, 12:10 PM
  5. Need with my assignment ...
    By allergy01 in forum New To Java
    Replies: 1
    Last Post: 04-25-2009, 08:33 AM

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
  •