0

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 by Nick Evan: Fixed formatting

3
Contributors
6
Replies
7
Views
5 Years
Discussion Span
Last Post by stultuske
0

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 by stultuske: method comment

0

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

0

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

0
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 by Nick Evan: Fixed formatting

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

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.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.