私はJavaを学んでいる最中です。今日の私の仕事は、コードのエラーを見つけることでした。私はそれに取り組んでいますが、次のエラーが発生する理由がわかりません。サンプル コードでは、「int momsAge= 42; dadsAge= 43;」の行に「.class expected」が表示されます。具体的には、momsAge のすぐ前にエラー行が表示されます。
// 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: */
http://mathworld.wolfram.com/SampleVariance.html
// define some ages
int momsAge= 42; dadsAge= 43;
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);
}
}