#I keep getting errors when I update eclipse still
7 messages · Page 1 of 1 (latest)
⌛ This post has been reserved for your question.
Hey @cyan ferry! Please use
/closeor theClose Postbutton above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
The error is saying that your main method doesn't have the static property. Could you post your code here to help confirm whether its an IDE problem or a code problem?
@cyan ferry copy and paste your code into here, specifically the main method
public class SumAndAverage {
public static void main(String[] args) {
if (args.length != 5) {
System.err.println("Please provide exactly 5 numbers as command-line arguments.");
System.exit(1);
}
double[] numbers = new double[5];
double sum = 0;
for (int i = 0; i < 5; i++) {
try {
numbers[i] = Double.parseDouble(args[i]);
} catch (NumberFormatException e) {
System.err.println("Invalid number format for argument " + (i + 1) + ": " + args[i]);
System.exit(2);
}
sum += numbers[i];
}
double average = sum / 5;
System.out.println("The sum is: " + sum);
System.out.println("The average is: " + average);
}
}
the file is named right so I don't know whats wrong with it