Help - Avg

Hello to all. I'm new to the Java world and taking a class online. The project that I'm working now is having a user enter age and weight of an indefinite number of people and then calculate the average age and weight. There is more to the project, but need to get this part first. Here is what I have so far:

/*

This program will allow the user to enter the age in years

and weight in pounds of an indefinite number of people. It

will then use a sentinel value to average the

data entered. The program will then calculate the average

weight and age for all the people. */

import java.util.*;

import java.text.DecimalFormat;

public class People911.java

{

public static void peopleAgesandWeight()

{

int people = 0

int agesTotal = 0;

double agesAverage = 0;

int ages;

/*Description of program for user.*/

System.out.println("This program will calculate the average");

System.out.println("age in years and weight in pounds of an");

System.out.println("indefinite number of people. \n");

System.out.println("Enter the ages when prompted.");

System.out.println("Enter -1 when you are done.");

System.out.println("\n\n");

System.out.println("Enter in ages. Press enter after each age. \n");

ages = scannerObject.nextInt();

System.out.println("Now enter the weights when prompted.");

System.out.println("Enter -1 when you are done. \n");

System.out.println("Enter in weights. Press enter after each weight.\n");

ages = scannerObject.nextInt();

/*While statement.*/

while (ages!= -1) /*While loop to enter. Enter -1 to exit*/

{

agesTotal += ages; /*Sums all the ages entered*/

people ++; /*Counts the number of ages entered*/

System.out.println("Enter another score or -1 to end.");

ages = scannerObject.nextInt();

} /*End of while loop.*/

System.out.println("\n");

agesAverage = agesTotal / ages; /*Calculates average

DecimalFormat twoDigits = new DecimalFormat ("0.00"); /*Create new DecimalFormat object*/

System.out.println("You entered" +ages+" years.");

System.out.println("The sum of your ages are" +agesTotal);

System.out.println("Your average age is " + twoDigits.format (agesAverage));

System.out.println("\n\n");

} /*End of method for data.*/

}

Am I in the ballpark?

Thanks in advance.

[2500 byte] By [r3dman1122a] at [2007-11-27 10:08:09]
# 1
> Am I in the ballpark?Well, is it working?When you post code, please use[code] and [/code] tags as described in Formatting tips on the message entry page. ( http://forum.java.sun.com/help.jspa?sec=formatting) It makes it much easier to read.
jverda at 2007-7-13 0:44:32 > top of Java-index,Java Essentials,New To Java...
# 2
I'm at work right now and thought I had all the tools I needed already installed. I'll run it when I get home and thanks for the link. I'll look at it now.
r3dman1122a at 2007-7-13 0:44:32 > top of Java-index,Java Essentials,New To Java...
# 3

> I'm at work right now and thought I had all the tools

> I needed already installed. I'll run it when I get

> home and thanks for the link. I'll look at it now.

Don't you think it kind of presumptuous to ask us to do the compiling and associated error checking before you do this yourself? Sheesh

petes1234a at 2007-7-13 0:44:32 > top of Java-index,Java Essentials,New To Java...