# Please tell me what i did incorrect

• September 27th, 2012, 08:24 AM
fh123boys
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);
}
• September 27th, 2012, 08:30 AM
Purple01
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. :)
• September 27th, 2012, 08:33 AM
fh123boys
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 :(
• September 27th, 2012, 08:33 AM
Purple01
Re: Please tell me what i did incorrect
Can you copy paste the red text?

P.s. I adjusted my firts post.
• September 27th, 2012, 08:36 AM
Purple01
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.
• September 27th, 2012, 08:40 AM
fh123boys
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);
}
• September 27th, 2012, 08:40 AM
fh123boys
Re: Please tell me what i did incorrect
How do i put it in code tags?
• September 27th, 2012, 08:42 AM
Purple01
Re: Please tell me what i did incorrect
And also mind the capital letters.
dogsAge = not the same as: DogsAge.

Good luck. :)
• September 27th, 2012, 08:42 AM
Purple01
Re: Please tell me what i did incorrect
Remove the *

[*code]
code here
[*/code]
• September 27th, 2012, 08:45 AM
fh123boys
Re: Please tell me what i did incorrect
It says" '.class' expected." at double momsAge= 42;...how do i fix it?
• September 27th, 2012, 08:47 AM
Purple01
Re: Please tell me what i did incorrect
I copy pasted your code in my program and these are your errors:

Code :

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

But since you need to define them all:
Code :

```double momsAge= 42; double dadsAge= 43; 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.
• September 27th, 2012, 08:49 AM
Purple01
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.)
• September 27th, 2012, 08:52 AM
fh123boys
Re: Please tell me what i did incorrect
still says class expected
• September 27th, 2012, 10:36 AM
jps
Re: Please tell me what i did incorrect
Quote:

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.
• September 27th, 2012, 11:30 AM
jps
Re: Please tell me what i did incorrect
Quote:

Originally Posted by fh123boys
still says class expected

Please post a fresh copy of the code and any error messages you have.