Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

>> REGISTER NOW TO START POSTING

1. ## Please tell me what i did incorrect

There are 7 errors in the following program...Tell me what i did incorrect and tell me how to fix it. Also, tell me where the errors are located and what type of errors i made, if they have a specific name
Do not worry about the math calculations, abbreviations, or missing words in comments. But, I am unfamiliar with writing programs, so worry about the way it is written

// A class that computes the sample statistics of the ages of
// family members.
public class FamilyStats
{
public static void main(String[] args)
{
/*
math equations obtained from: */
Sample Variance -- from Wolfram MathWorld

// define some ages

int myAge= 22, sistersAge= 16;
int dogsAge= 6;

// get the mean

double ageSum = (momsAge + dadsAge + myAge + sistersAge + DogsAge);
double average = ageSum / 5

/ calculate the sample variance
double variance= 0.0;
variance += (momsAge - average)*(momsAge - average);
variance += (myAge - average)*(myAge - average);
variance += (sistersAge - average)*(sistersAge - average);
variance += (dogsAge - average)*(dogsAge - average);
variance = variance / 4;

// get the std. dev
double standardDev= Math.sqrt(variance);
// output the results
System.out.println(The sample age mean is: + average);
System.out.println("The sample age variance is: " + variance);
System.out.println("The sample age standard deviation is: " + standardDev);
}

2. ## Re: Please tell me what i did incorrect

What are the errors?

I think you do need to change these int's in doubles:

int momsAge

Becasue else you won't get out a double value below hen you calculate the mean.

Als try putting your code between code tags.
Then it is easyer to read.

3. ## Re: Please tell me what i did incorrect

I do not know. I was told that i had 7 errors and i have looked at it for hours and havent found any, but there ARE 7 ...i am too inexperienced to notice them though

4. ## Re: Please tell me what i did incorrect

Can you copy paste the red text?

P.s. I adjusted my firts post.

5. ## Re: Please tell me what i did incorrect

Also I think by looking at you code, that dadsAge is not defined as an int/double.

Maybe you should make it:

double momsAge= 42;
double myAge= 22;
double sistersAge= 16;
double dogsAge= 6;

Also you have a , between myAge and sistersAge.
That is sure causing 1 error.

6. ## Re: Please tell me what i did incorrect

// A class that computes the sample statistics of the ages of
// family members.
public class FamilyStats
{
public static void main(String[] args)
{
/
math equations obtained from: /
Sample Variance -- from Wolfram MathWorld

// define some ages

int myAge= 22, sistersAge= 16;
int dogsAge= 6;

// get the mean

double ageSum = (momsAge + dadsAge + myAge + sistersAge + DogsAge);
double average = ageSum / 5

/ calculate the sample variance
double variance= 0.0;
variance += (momsAge - average)*(momsAge - average);
variance += (myAge - average)*(myAge - average);
variance += (sistersAge - average)*(sistersAge - average);
variance += (dogsAge - average)*(dogsAge - average);
variance = variance / 4;

// get the std. dev
double standardDev= Math.sqrt(variance);
// output the results
System.out.println(The sample age mean is: + average);
System.out.println("The sample age variance is: " + variance);
System.out.println("The sample age standard deviation is: " + standardDev);
}

7. ## Re: Please tell me what i did incorrect

How do i put it in code tags?

8. ## Re: Please tell me what i did incorrect

And also mind the capital letters.
dogsAge = not the same as: DogsAge.

Good luck.

Remove the *

[*code]
code here
[*/code]

10. ## Re: Please tell me what i did incorrect

It says" '.class' expected." at double momsAge= 42;...how do i fix it?

11. ## Re: Please tell me what i did incorrect

I copy pasted your code in my program and these are your errors:

```int momsAge= 42; dadsAge= 43;
int myAge= 22, sistersAge= 16;
int dogsAge= 6;```

But since you need to define them all:
```double momsAge= 42;
double myAge= 22;
double sistersAge= 16;
double dogsAge= 6;```

Also in your code you have a , between myAge and sistersAge.
And int cannot have text in it, only numbers.

And dogsAge = not the same as DogsAge.

And voila, it should work I think.

12. ## Re: Please tell me what i did incorrect

What if you would make it: 42.0?

(I am going home now, I am finished working, might look in this topic in 1 hours again. Good luck.)

13. ## Re: Please tell me what i did incorrect

still says class expected

14. ## Re: Please tell me what i did incorrect

Originally Posted by Purple01
Also you have a , between myAge and sistersAge.
That is sure causing 1 error.
The following line of code:
int myAge= 22, sistersAge= 16;
Is perfectly legal java syntax.

15. ## Re: Please tell me what i did incorrect

Originally Posted by fh123boys
still says class expected
Please post a fresh copy of the code and any error messages you have.