Results 1 to 3 of 3
Thread: Program help/ Integers
- 11-29-2012, 01:45 AM #1
Member
- Join Date
- Nov 2012
- Posts
- 4
- Rep Power
- 0
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.io.*;
import java.util.*;
public class Chp5_ProgEx2
{
public static void main(String[] args)
{
int = sum
int = num
sum = 0;
num = infile.nextInt();
- 11-29-2012, 04:19 AM #2
Senior Member
- Join Date
- Jun 2007
- Location
- Bali, Indonesia
- Posts
- 696
- Rep Power
- 6
Re: Program help/ Integers
Hi,
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 (%).Website: Learn Java by Examples
- 11-29-2012, 01:33 PM #3
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
-
Write a Java program that reads integers finds the largest and counts its occurrence.
By bobbyj7 in forum New To JavaReplies: 2Last Post: 10-06-2012, 04:29 AM -
help with randomizing integers
By tom2zip in forum New To JavaReplies: 5Last Post: 11-27-2011, 11:30 PM -
Program to read integers until a specific number?
By equal in forum New To JavaReplies: 5Last Post: 11-17-2010, 05:53 PM -
Set of Integers
By rsjava24 in forum New To JavaReplies: 7Last Post: 01-28-2010, 10:29 AM -
How to ask for several integers from the program user?
By busdude in forum New To JavaReplies: 1Last Post: 10-20-2008, 07:55 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks