The same think about updateBirthDateTotal keep it as is:

public void updateBirthDateTotal()
	{
		birthDateTotal++;
	}

The formatMonth function seems to be correct

public String formatMonth()
	{
		String birthDateMo;
		if (birthDateMonth == 01)
			birthDateFormattedMon = "January";
		else if (birthDateMonth == 02)
			birthDateFormattedMon = "February";
		else if (birthDateMonth == 03)
			birthDateFormattedMon = "March";
		else if (birthDateMonth == 04)
			birthDateFormattedMon = "April";
		else if (birthDateMonth == 05)
			birthDateFormattedMon = "May";
		else if (birthDateMonth == 06)
			birthDateFormattedMon = "June";
		else if (birthDateMonth == 07)
			birthDateFormattedMon = "July";
		else if (birthDateMonth == 8)
			birthDateFormattedMon = "August";
		else if (birthDateMonth == 9)
			birthDateFormattedMon= "September";
		else if (birthDateMonth == 10)
			birthDateFormattedMon= "October";
		else if (birthDateMonth == 11)
			birthDateFormattedMon = "November";
		else
			birthDateFormattedMon = "December";
		return birthDateFormattedMon;
	}

but I suggest to use the switch statement instead of the ifs what do you think?

ok, keeping those as they are.
are we going to put the functions together in MAIN afterward?

No we just put the befor the main function in the body of the calss

um something like this?

switch( ???)
{
	case '01': birthDateFormattedMon = "January";
			break;
	case '02': birthDateFormattedMon = "February";
			break;

}

oh i'm not sure wht goes in those parens after 'switch'

If you are agreed the fuction will be like follow:

public void formatMonth() {
        switch (birthDateMonth) {
            case 1:
                birthDateFormattedMon = "January";
                break;
            case 2:
                birthDateFormattedMon = "February";
                break;
            case 3:
                birthDateFormattedMon = "March";
                break;
            case 4:
                birthDateFormattedMon = "April";
                break;
            case 5:
                birthDateFormattedMon = "May";
                break;
            case 6:
                birthDateFormattedMon = "June";
                break;
            case 7:
                birthDateFormattedMon = "July";
                break;
            case 8:
                birthDateFormattedMon = "August";
                break;
            case 9:
                birthDateFormattedMon = "September";
                break;
            case 10:
                birthDateFormattedMon = "October";
                break;
            case 11:
                birthDateFormattedMon = "November";
                break;
            case 12:
                birthDateFormattedMon = "December";
                break;
            default:
                System.out.println("Invalid month.");
                break;
        }
    }

if it is so let me now to update my code.

oh, yes you are right. I see what I did wrong. Alright, so far so good still running "successful"!

the write functions will remain the same, right?

So you opte to use the switch statement?

oh, yes I used the switch statement it looks much easier to read compared to the if else statments :)

so i added the writeOutcomes function and it reports sucessful
but when i add the writeStudentData function, i run into errors.

Please just focus on what we are talking about!

Well let’s go with checkBirthDate
If I understand this function must takes two parameters of type Profile and return a boolean value : true if the two parameters have the same birth date false if not; if it is so it could be like that:

/**
     * Tests if two stuents have the same BirthDate
     * @param firstStudent 
     * @param secondStudent
     * @return true if the firstStudent and secondStudent have the same BirthDate false otherwise
     */
    public static boolean checkBirthDate(Profile firstStudent, Profile secondStudent) {
        return ((firstStudent.getBirthDateDay() == secondStudent.getBirthDateDay())
                && (firstStudent.getBirthDateMonth() == secondStudent.getBirthDateMonth())
                && (firstStudent.getBirthDateYear() == secondStudent.getBirthDateYear()));
    }

yes, you have understood that function, that's exactly what it's suppose to do.

oh actually no, we are not comparing students we are comparing the birth date of the student to a preset birthdate

like the system should have Feb 29th fed into it already
each student's birthDate should be compared to that and
if they match then we increment the number of students with the Feb.29th birthDate or we just move on.

get what i mean?

we are comparing the student object values to the base so wouldn't this just be fine:

public boolean ckBirthDate (Profile stud)
{
        return((birthDateMonth == stud.birthDateMonth) && (birthDateDay == stud.birthDateDay))?true:false;
}

Sorry I did not understand your proposal!
Is it correct or not my suggestion? if it is we will ga with checkOldestBirthDate

sorry maybe i just got it all confused up but according to your proposal it seems as if we are comparing two student's birthDates, right?
1st student object birth date vs 2nd student object birth date

But, i think we are suppose to have a base object and compare the student's birth date to that like:
student object birth date (mm/dd/yyyy) vs base object birth date (02/29)

the base will hold the month: 02 and day: 29
and if the student's birth day is 02/29 then after it compares to the base object it will add one to the "updateBirthDateTotal"

I dont think the ckBirthDate method is written right, do you see why? or am I getting something wrong?

I did not now but the reqirement said:
checkBirthDate – check if the two objects have the same month and date
Here is not mentionned any base object nither the date format, it juste tell to compare two objects.
and there is no mention that tell that the base student will have the month 2 and the day 29.
and it does tell that the comparaison is based on the base sudent.
In fact this is what I understand but it's up to you to tell what is the requirements.

After all the above function can do what you said if we give it a base object asa parameter with another object.

oh i'm sorry for not clarifying, but so I think in total we have three objects right?

OBJECT #1: student this will hold the values of the current student being processed, whose values are compared to the other two objects.

OBJECT#2: oldestStudent ["1999", "12", "31"] <-- the current student's values will be compared to these values. If that student is older then his/her values (that are in the student object) will be copied over to the oldestStudent (the 1999, 12, 31 will be replaced by the new oldest student's birth date)

OBJECT #3: base ["02", "29"] <-- the current student's birth date will also be compared to these values to check if the student has a Feb.29th bday, if they do then we will add to the total number of students w/ Feb 29th bdays or else just move on


looking at that suggestion of your there were two objects: firstStudent & secondStudent, I dont think those are right because of this, do you see what i mean?

i'm just following the example we did in class and thats how its set up but the only diff is that this program has more objects and I dont know how to deal with that. sorry if i have just complicated things or confused you on anything :(

Well what's you suggestion?

see this is where most of my struggle was because i dont know how to work with multiple objects, constructors and link them.

um i guess as a first step we would add the two objects?
idk wht do you think? I'm lost & confused now!

so if this portion in main looks like this (it errors idk y?):

public static void main (String[] args)
{
	Profile p = new Profile ()
	Profile oldestStudent = new Profile ('1999', '12', '31');
	Profile base = new Profile('02', '29');

p.readData()

this errors as cannot find symbol and what not :(

You just need to add those constructors in the profile class:

public Profile(int year, int month, int day) {
        birthDateYear=year;
        birthDateMonth=month;
        birthDateDay=day;
    }
    
    public Profile(int month, int day) {
        birthDateMonth=month;
        birthDateDay=day;
    }

and the you can do in the main function some thing like:

Profile p = new Profile ()
	Profile oldestStudent = new Profile (1999, 12, 31);
	Profile base = new Profile(02, 29);
     p.readData();

ok that make sense, I went ahead and then I went ahead and added this function in like this:

public boolean checkBirthDate (Profile stud)
	{
		return((birthDateMonth == stud.birthDateMonth) && (birthDateDay == stud.birthDateDay))?true:false;
	}

well I'll take this chage in my code.

also then for the next step I went ahead and entered this portion in and it works:

public boolean ckOldestBirthDate(Profile p, Profile oldestStu)
	{
		boolean birthDate = false;

		if (p.birthDateYear < oldestStu.birthDateYear)
			birthDate = true;
		else if (p.birthDateYear == oldestStu.birthDateYear)
			if (p.birthDateMonth < oldestStu.birthDateMonth)
				birthDate = true;
			else if (p.birthDateMonth == oldestStu.birthDateMonth)
				if (p.birthDateDay < oldestStu.birthDateDay)
					birthDate = true;
				else
					birthDate = false;
			else
				birthDate = false;
		else
			birthDate = false;
		return birthDate;
	}

for the update Oldest Birth date method I added:

public void updateOldestBirthDate(Profile oldestStu, Profile p)
	{
		oldestStu = p;
	}

by the way I am just writing these methods, but haven't put them together in the MAIN yet, so the complier isn't giving any errors but i'm not sure if they work logic wise, if you get wht i mean!

For the ckOldestBirthDate I suggest that following code take a time to stading it:

public static Profile checkOldestBirthDate(Profile firstStudent, Profile secondStudent) {
        Calendar calFirstStudent = Calendar.getInstance();
        Calendar calSecondStudent = Calendar.getInstance();
        calFirstStudent.set(firstStudent.getBirthDateYear(), firstStudent.getBirthDateMonth(), firstStudent.getBirthDateDay());
        calSecondStudent.set(secondStudent.getBirthDateYear(), secondStudent.getBirthDateMonth(), secondStudent.getBirthDateDay());

        return (calFirstStudent.after(calSecondStudent) ? secondStudent : firstStudent);
    }

That function returns the oldest student

Instead of returning a boolean value; what that mean returnning a Boolean value; what semantic it provide?

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.