I was attempting to run a project that my teacher in AP Computer Science supplied us with to check our work. I have been trying for two classes to get the teacher's code to work but to no avail. The problem is that when the private variable n is initialized it gives me an error reading "illegal start of expression." Any help would be much appreciated. This is the code:
package eastersunday;
public class Easter
{
public static void main(String[] args)
{
private int n;
private int p;
/**
Constructs the date of Easter Sunday.
* @param year
*/
public Easter(int year)
{
int y = year;
int a = y % 19;
int b = y / 100;
int c = y % 100;
int d = b / 4;
int e = b % 4;
int g = (8 * b + 13) / 25;
int h = (19 * a + b - d - g + 15) % 30;
int j = c / 4;
int k = c % 4;
int m = (a + 11 * h) / 319;
int r = (2 * e + 2 * j - k - h + m + 32) % 7;
n = (h - m + r + 90) / 25;
p = (h - m + r + n + 19) % 32;
}
/**
Gets the month of Easter Sunday
@return month of Easter Sunday
*/
public int getEasterSundayMonth()
{
return n;
}
/**
Gets the date of Easter Sunday
@return date of Easter Sunday
*/
public int getEasterSundayDay()
{
return p;
}
}
One issue I see at a glance: you have some dangling brackets in your code. This makes it so you are declaring things within main, which you may or may not have intended, because you didn't close it with '}'. Make sure every { closes with a } or your code will give you some errors.