I'm not sure why, the compiler error points at the string Array. should i make a for loop and manually fill each subscript with a name of the months for the year? please help!!
import java.util.*;
public class Rainfallmain
{
public static void main(String [] args)
{
double months = 12;
double average = Rainfallyr.getAverage();
double Mostrain = Rainfallyr.getHighest();
double Leastrain = Rainfallyr.getLowest();
double total = Rainfallyr.getTotal();
double [] Rainfallyr = new Rainfall[months];
String[] Mon = {"January", "Febuary", "March", "April", "May", "June", "July", "August". "September", "October", "November", "December"};
getRainvalues(Rainfallyr, mon);
System.out.println(" The total rainfall for the year is " + Mostrain);
System.out.println(" The total least aount of rain is " + Leastrain);
System.out.println(" The total rainfall for the year is " + total);
System.out.println(" The average rainfall for the year is " + average);
}
}
public static void getAllvalues(double []rain, String [] mon)
{
Scanner input = new Scanner(System.in);
for(int i = 0; i < r.length; i++)
{
System.out.print(" Enter Rain for each month" +mon[i]+" :");
r[i] = input.nextDouble();
}
}
答案 0 :(得分:2)
"August". "September"
The member-access operator .
needs to be followed by an identifier (the name of the member being accessed), not a string literal. That's why the error message says "identifier expected".
You probably meant to use a comma there.