Sum of all even integers

E

ericcc

"Use WHILE. Write an application that asks the user to input integers,
calculates the sum of all even integers, and displays the result.
Allow the user to decide when to quit."

So far this is what I have:
import java.util.Scanner;

public class Sum
{
public static void main(String[] args)
{
// declare and initialize variables
int count;
double total, sum;
String integer;

count = 0;
total = 0;
String another = "y";

Scanner in = new Scanner(System.in);

// while the user inputs yes to continue
while ((another.toUpperCase()).equals("Y"))
{
// Ask the user to input the integer
System.out.println("Enter an integer: ");
integer = in.next();

// help!

// check if the user wants to continue
System.out.println("Would you like to enter another
integer (y/n): ");
another = in.next();
}

// calculate the sum
// help!

// display the average
System.out.println("The sum of all even integers is " + sum);
}
}
 
L

Lew

ericcc said:
"Use WHILE. Write an application that asks the user to input integers,
calculates the sum of all even integers, and displays the result.
Allow the user to decide when to quit."

Check out Roedy's answers in the other group to which you multiposted,
comp.lang.java.help.

Please do not multipost. It fragments the conversation and makes it
annoyingly hard to follow. If you really, really, really, really feel that
you absolutely cannot live without reaching multiple groups (even though
they're mostly the same people), then cross-post, preferably setting one of
the groups as your followup (a.k.a., "f/u" or "f-u" in some folks'
abbreviation lexicon).
 
E

ericcc

Check out Roedy's answers in the other group to which you multiposted,
comp.lang.java.help.

Please do not multipost. It fragments the conversation and makes it
annoyingly hard to follow. If you really, really, really, really feel that
you absolutely cannot live without reaching multiple groups (even though
they're mostly the same people), then cross-post, preferably setting one of
the groups as your followup (a.k.a., "f/u" or "f-u" in some folks'
abbreviation lexicon).

sorry for multiposting. after i posted in this one i discovered
comp.lang.java.help and thought my question should go in there instead
of in here.
 
L

Lew

ericcc said:
sorry for multiposting. after i posted in this one i discovered
comp.lang.java.help and thought my question should go in there instead
of in here.

Just to help you out, here's an idea. Instead of starting a new thread on an
extant question (obviously not relevant for something really, really old),
continue the thread with cross-posting, as I did to unify your multiposts.

Even that is likely not to be very helpful, really. Mostly the same people
read and answer questions in both clj.help and clj.programming, so by
multiposting you are actually discouraging the most knowledgeable people from
wanting to help. By sticking with one group or the other, you're getting
substantially the same audience.

It's a good idea to read up on Usenet etiquette, a.k.a., "netiquette". Among
other resources is the "comp.lang.java.{help,programmer} - what they're for
(mini-FAQ 2006-03-31)" message, reposted every few days in both groups so that
everyone has no excuse not to read it. (Notice that it subsumes both the
clj.help and clj.programmer groups, a big, fat clue that they're related.)

Among other things, it advises:
Don't cross-post between these groups and c.l.j.programmer or .help -- it just
wastes the time of people reading the general groups.

It also mentions, and links to explanations for, SSCCE (RTFM)
Before posting read Jon Skeet's "How to get answers on the comp.lang.java.*
newsgroups" at
<http://www.pobox.com/~skeet/java/newsgroups.html>

The first sentence in that last link after the introductory paragraph is:
Don't multi-post.

RTFM.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top