Results 1 to 3 of 3
  1. #1
    KMayers is offline Member
    Join Date
    Nov 2012
    Rep Power

    Question Program help/ Integers

    I am new to Java
    How do I write a program for the following

    Write a program that reads a set of integers and then finds and prints the sum of the even and odd integers

    This is what I have so far:

    import java.util.*;

    public class Chp5_ProgEx2
    public static void main(String[] args)

    int = sum
    int = num

    sum = 0;
    num = infile.nextInt();

  2. #2
    wsaryada is offline Senior Member
    Join Date
    Jun 2007
    Bali, Indonesia
    Rep Power

    Default Re: Program help/ Integers


    Your program doesn't compile, it is not complete. Please put some more effort to it. :)

    To read user you can utilize the java.util.Scanner class. It has a set of method that allows you to read integer data. And then calculates this numbers to get the sum. To know if the number is even or odd you can use the modulo operator (%).

  3. #3
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Rep Power

    Default Re: Program help/ Integers

    Hello and welcome! Please use [code][/code] tags when posting code so we can easily read it!

    Forum Rules
    Guide For New Members
    BB Code List - Java Programming Forum

Similar Threads

  1. Replies: 2
    Last Post: 10-06-2012, 04:29 AM
  2. help with randomizing integers
    By tom2zip in forum New To Java
    Replies: 5
    Last Post: 11-27-2011, 11:30 PM
  3. Replies: 5
    Last Post: 11-17-2010, 05:53 PM
  4. Set of Integers
    By rsjava24 in forum New To Java
    Replies: 7
    Last Post: 01-28-2010, 10:29 AM
  5. Replies: 1
    Last Post: 10-20-2008, 07:55 PM

Posting Permissions

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