I'm getting Error: <identifier> expected and not sure why, any tips?

public class BioCalc
{
// instance variables
private Date myToday;//Date object today
private Date myBday;//Date object birthday
private int myDaysAlive;//birthday-today
private final int PCYCLE=23;//physical length
private final int ECYCLE=28;//emotional length
private final int ICYCLE=33;//intellectual length
/**
* Constructor for objects of class BioCalc
*/
public BioCalc(Date myToday,Date myBday)
{
//initialize instance variables
int myDaysAlive = myBday.daysBetween(myToday);//calculates days alive
}

Edited 3 Years Ago by Nick Evan: Fixed formatting

because you're missing a '}'?
you sure are missing one at the end of the code you've posted.

or maybe because you are using a non-existing daysBetween method.

Edited 5 Years Ago by stultuske: method comment

this is simply the start of the class.
Also the daysBetween method is a method of the Days clas

GThe error message includes the exact location where the error was found. Whay not share that info with us? It really would help.

public class BioCalc
{
// instance variables
private Date myToday;//Date object today
private Date myBday;//Date object birthday
private int myDaysAlive;//birthday-today
private final int PCYCLE=23;//physical length
private final int ECYCLE=28;//emotional length
private final int ICYCLE=33;//intellectual length
/**
* Constructor for objects of class BioCalc
*/
public BioCalc(Date myToday,Date myBday)
{
//initialize instance variables
int myDaysAlive = myBday.daysBetween(myToday);//calculates days alive
}


/**
* This method will calculate and return the physical biorhythm
*
* @return     the location the user is at in the physical biorhythm
*/
public int getPhysical()
{
// calculates physicalcycle
int physicalCycle = myDaysAlive%PCYCLE;
return physicalCycle;
}


/**
* This method will calculate and return the emotional biorhythm
*
* @return     the location the user is at in the emotional biorhythm
*/
public int getEmotional()
{
// calculates emotional cycle
int emotionalCycle = myDaysAlive%ECYCLE;
return emotionalCycle;
}


/**
* This method will calculate and return the intellectual biorhythm
*
* @return     the location the user is at in the intellectual biorhythm
*/
public int getIntellectual()
{
// calculates intellectual cycle
int intellectualCycle = myDaysAlive%ICYCLE;
return intellectualCycle;
}


public int getDaysBetween(){return myDaysAlive;}
}

Edited 3 Years Ago by Nick Evan: Fixed formatting

Attachments Screen_Shot_2011-11-14_at_8.51_.13_PM_.png 36.35 KB

and what does the error message tell you? it usually shows the exact line of code in which there is a problem.

This article has been dead for over six months. Start a new discussion instead.