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
}

Recommended Answers

All 6 Replies

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.

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.

plus: how can we say weither you've missed something in that code, if you don't show the entire method?

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;}
}

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.