I can't find anything wrong with this but somehow it's wrong.
I'm in an AP CS class and I was given an assignment that required me to find and correct mistakes. I opened the program and it tells me (on BlueJ)after I try to compile it '.class' expected. I haven't gotten that far into my class to know what that means. Can anyone explain. Code:
public class FamilyStats
{
public static void main(String args [])
{
/*
math equations obtained from: */
http://mathworld.wolfram.com/SampleVariance.html
// define some ages
int momsAge= 42; int dadsAge= 43; <---This line shows the first problem. 7 in all.
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 += (dadsAge - average)(dadsAge - 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);
}
:frusty:
Re: I can't find anything wrong with this but somehow it's wrong.
-First, take a look at line 7 and 19 and fix the comments :D
-Count the braces
-check upper and lowercase
- ; is necessary in java
- (dadsAge - average)(dadsAge - average) missing sign?
- compare each System.out to the other....
Re: I can't find anything wrong with this but somehow it's wrong.
Thanks for the help. I guess I just needed someone lay it out differently.