Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2012
    Posts
    4
    Rep Power
    0

    Default 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.
    Java 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);
    }

  2. #2
    eRaaaa is online now Senior Member
    Join Date
    Oct 2010
    Location
    Germany
    Posts
    787
    Rep Power
    5

    Default 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....

  3. #3
    Join Date
    Sep 2012
    Posts
    4
    Rep Power
    0

    Default 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.

Similar Threads

  1. Replies: 4
    Last Post: 06-11-2013, 01:37 AM
  2. I don't find where I did wrong ...
    By allexif in forum New To Java
    Replies: 5
    Last Post: 04-23-2012, 03:57 AM
  3. Something is Wrong O.o
    By Spidermonkey in forum Advanced Java
    Replies: 16
    Last Post: 11-14-2010, 04:33 AM
  4. what wrong
    By pro85 in forum New To Java
    Replies: 3
    Last Post: 02-09-2009, 01:07 PM
  5. what's wrong in here!!!
    By Annatar in forum New To Java
    Replies: 8
    Last Post: 11-14-2008, 02:55 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •