Here is the program that needs to be done

You are to prompt the user for a 3-digit ID and a birthdate for each college student. For the birth date, prompt for 2 intergers in order month, day, and year. Be sure to validate the birth date. The last student ID will be 000.

You are to out the ID and birth date for each student. The birth date should be output in the format February 15, 1982. Also output how many students were processed, how many of the students had a February 29th birth date, and the birth date of the oldest student.

HERE IS WHAT I HAVE AS OF NOW

import java.util.Scanner;
public class StudentBirthdate
{
    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();
            while(!(p.studentId.equals("000")))
            {
                if (p.dataValid(p))
                {
                    p.totalStudents();
                    if (base.ckBirthDate(p))
                        p.updateBirthDateTotal();

                    p.formatMonth();
                    p.writeStudentData(p);
                    p.readData();
                }
            }
            p.writeOutcomes();
    }
}




import java.util.Scanner;
public class Profile
{
    public String studentId;
    private String birthDateFormattedMon;
    private int birthDateMonth;
    private int birthDateDay;
    private int birthDateYear;
    private static int totalStudents;
    private static int birthDateTotal;
    private static int NumStudents;
    Profile()
    {NumStudents++;}
    Profile (int bdayDay, int bdayMonth, int bdayYear)
    {
        birthDateDay = bdayDay;
        birthDateMonth = bdayMonth;
        birthDateYear = bdayYear;
        NumStudents++;
    }

    public Profile(int month, int day)
    {
        birthDateMonth=month;
        birthDateDay=day;
        NumStudents++;
    }
    public int getBirthDateDay()
    {
        return birthDateDay;
    }
    public int getBirthDateMonth()
    {
        return birthDateMonth;
    }
    public int getBirthDateYear()
    {
        return birthDateYear;
    }
    public String getStudentId()
    {
        return studentId;
    }
    public void readData()
            {
                Scanner input = new Scanner(System.in);
                System.out.print("Enter a 3-digit student id:");
                studentId = input.next();
                        if(studentId.equals("000")) return;
                System.out.print("Enter month of birth date: ");
                birthDateMonth = input.nextInt();
                System.out.print("Enter day of birth date: ");
                birthDateDay = input.nextInt();
                System.out.print("Enter year of birth date: ");
                birthDateYear = input.nextInt();
         }
        public boolean dataValid (Profile stud)
        {
            boolean validate = true;
            if ((birthDateMonth < 01)||(birthDateMonth > 12))
            {
                validate = false;
                System.out.println("Month must be b/w the range 01-12 inclusive.");
            }
            if ((birthDateDay < 01) || (birthDateDay > 31))
            {
                validate = false;
                System.out.println("Day must be b/w the range 01-31 inclusive.");
            }
            if ((birthDateYear < 1900) || (birthDateYear > 1999))
            {
                validate = false;
                System.out.println("Year must be b/w the range 1900-1999 inclusive.");
            }
            return validate;
        }
            public void totalStudents()
            {
                totalStudents++;
            }
            public void updateBirthDateTotal()
            {
                birthDateTotal++;

            }

        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 = "Decemember";
            }
        }
        public boolean ckBirthDate (Profile stud)
        {
            return((birthDateMonth == stud.birthDateMonth) && (birthDateDay == stud.birthDateDay))?true:false;
        }

        public static void writeOutcomes()
        {
            System.out.println(totalStudents + "students were processed.");
            System.out.println(birthDateTotal + "students had a February 29th birth date.");

        }
        public static void writeStudentData(Profile p)
        {
            System.out.println("Student Id: " + p.studentId);
            System.out.println("Birth Date: " + p.birthDateFormattedMon + p.birthDateDay + "," + p.birthDateYear);
        }
        public static int getNumStudents()
        {
            return NumStudents;
        }
}

i already output the ID, the birthdate, how many students were processed, EXCEPT the birth date of the oldest student. can you help me please Taywin

OK, line 40, the name NumStudents is not conventional. It should be numStudents (notice the capital N). The variable name should be changed through out the whole program as well.

OK, first line 42, you should do nothing in your constructor because you has not yet process any student when you initiate the class instance. Otherwise, your count will be off by 1.

Now, I have to talk about how you design your program...

The requirement is asking you to implement a class that take in student ID, birth year, birth month, and birth day of each student. One requirement is that you need to keep track of who has the same birthday as a defined birthday. The other requirement is that you need to keep track who is the oldest.

Your current program is very simple and brute-force. The good thing is that it is simple by keeping tracks of year, month, and day in integer. The bad thing is that it does not keeping any record of what your requirements are asking for.

I don't want to discourage you, but I want you to understand the fundamental of how to program. So, I would like to encourage you to look at at least 2 classes - SimpleDateFormat and Date. Then you should look at how to compare date here. The example includes how to display the date in any format you want (which can be applied to your requirement).

Once you are done and understood the above paragraph, you can now be able to compare dates. Next step is to rewrite your date portion in your class. Simply remove all int variables of year, month, and day, and replace them with a Date variable for oldestDate. You would also need to adjust the way you assign/retrieve the birthday to your new Date variable. Doing so, you would no longer need getBirthDateDay(), getBirthDateMonth(), and getBirthDateYear(). Instead, you would have only getBirthDate() or something like that.

In your class, you should also have 2 variables (i.e. numStudents, and numStudentFeb29). These will keep track of total number of students seen and students whose birth month is on February 29.

Now, going through your main program, you no longer need multiple instances of your Profile class. You simply implement checkBirthday(int year, int month, int day). Inside the method, you simply check if the date is valid first. If it is valid, check if it is before your current oldest. If so, reassign the date to your variable. Then check if the incoming day & month is what you want (Feb 29). If it is, increment the count for numStudentFeb29. Lastly, increment numStudents by one.

It is a bit long process and could simply revamp your current program, but it would help you practicing on your programming concept and data type choices. It is important to know what already there and reuse them in order to make it clear.

Hope this help.

if i understand it correctly you want me to change the value of month, day, and year right? But the program says prompt 3 integers in the order month, day, and year.

thats the reason why i use int values. but is it okay to use the one you are suggesting?

jeram ... I already told you repeatedly what to do.
you are going back to questions that are already answered.

the only way we can make it any clearer is by writing the code for you, and the community rules prohibit this.

    import java.util.Scanner;
    public class StudentBirthdate
    {
        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();
                while(!(p.studentId.equals("000")))
                {
                    if (p.dataValid(p))
                    {
                        p.totalStudents();
                        if (base.ckBirthDate(p))
                            p.updateBirthDateTotal();
                        if (p.ckOldestBirthDate(p, oldestStudent))
                            oldestStudent.updateOldestBirthdate(p, oldestStudent);
                        p.formatMonth();
                        p.writeStudentData(p);
                        p.readData();
                    }
                }
                p.writeOutcomes();
        }
    }

import java.util.Scanner;
public class Profile
{
    public String studentId;
    private String birthDateFormattedMon;
    private int birthDateMonth;
    private int birthDateDay;
    private int birthDateYear;
    private static int totalStudents;
    private static int birthDateTotal;
    private static int numStudents;
    private static int oldestBirthDate;
    private static int oldestStu;
    Profile()
    {numStudents++;}
    Profile (int bdayDay, int bdayMonth, int bdayYear)
    {
        birthDateDay = bdayDay;
        birthDateMonth = bdayMonth;
        birthDateYear = bdayYear;
        numStudents++;
    }

    public Profile(int month, int day)
    {
        birthDateMonth=month;
        birthDateDay=day;
        numStudents++;
    }
    public int getBirthDateDay()
    {
        return birthDateDay;
    }
    public int getBirthDateMonth()
    {
        return birthDateMonth;
    }
    public int getBirthDateYear()
    {
        return birthDateYear;
    }
    public String getStudentId()
    {
        return studentId;
    }
    public void readData()
            {
                Scanner input = new Scanner(System.in);
                System.out.print("Enter a 3-digit student id:");
                studentId = input.next();
                        if(studentId.equals("000")) return;
                System.out.print("Enter month of birth date: ");
                birthDateMonth = input.nextInt();
                System.out.print("Enter day of birth date: ");
                birthDateDay = input.nextInt();
                System.out.print("Enter year of birth date: ");
                birthDateYear = input.nextInt();
         }
        public boolean dataValid (Profile stud)
        {
            boolean validate = true;
            if ((birthDateMonth < 01)||(birthDateMonth > 12))
            {
                validate = false;
                System.out.println("Month must be b/w the range 01-12 inclusive.");
            }
            if ((birthDateDay < 01) || (birthDateDay > 31))
            {
                validate = false;
                System.out.println("Day must be b/w the range 01-31 inclusive.");
            }
            if ((birthDateYear < 1900) || (birthDateYear > 1999))
            {
                validate = false;
                System.out.println("Year must be b/w the range 1900-1999 inclusive.");
            }
            return validate;
        }
            public void totalStudents()
            {
                totalStudents++;
            }
            public void updateBirthDateTotal()
            {
                birthDateTotal++;

            }

        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 = "Decemember";
            }
        }
        public boolean ckBirthDate (Profile stud)
        {
            return((birthDateMonth == stud.birthDateMonth) && (birthDateDay == stud.birthDateDay))?true:false;
        }
                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;
                }
        public void updateOldestBirthdate(Profile oldestStu, Profile p)
        {
                            oldestStu = p;
        }

        public static void writeOutcomes()
        {
            System.out.println(totalStudents + "students were processed.");
            System.out.println(birthDateTotal + "students had a February 29th birth date.");
            System.out.println(oldestStu + "oldest.");

        }
        public static void writeStudentData(Profile p)
        {
            System.out.println("Student Id: " + p.studentId);
            System.out.println("Birth Date: " + p.birthDateFormattedMon + p.birthDateDay + "," + p.birthDateYear);
        }
        public static int getNumStudents()
        {
            return numStudents;
        }
}

can you check line 17
line 149
and line 168

no ...
I'm done trying to explain to you why these lines make no sense.
I've explained you why those lines are wrong, what is wrong with them, and how to correct them.
If you choose to ignore the aid given to you, that is your choice, but then you should realize there is no reason you should repeat the questions.

please, do us both a favor, re-read the answers given to you, and act on them.

ok i will try but correct me if im wrong

that we will help you with.

I think you have a long way to learn... I will help you get started on the design part for now, so that you will see why your current design is so bad and not follows the requirement. Below is a skeleton code for your Profile class. It should cover all of requirements in the class (except you must implement method definitions yourself). I even give you what you need to do inside each method. This would show how simple your Profile class could be. If you still have any question, please ask.

import java.util.Scanner;
import java.util.Date;
import java.util.SimpleDateFormat;

public class Profile {
  // add all of your private variables
  private String studentId;
  private Date oldestDate = new Date();  // initial to today
  private int numStudents;
  private int numStudentsFeb29;

  public Profile() { }  // do nothing

  public void ckBirthdate(int year, int month, int day) {
    // *** implement this method definition ***
    // first create a new Date object using arguments given
    // ensure that the date you created is valid; otherwise, stop
    // then compare it with the oldestDate
    // if the new date is before oldestDate,
    //   assign the new date to oldestDate
    // now, check if the month & day are what you expected
    // this portion could be hard-coded for now
    // if it is equal to the month & day you want,
    //   increment the numStudentsFeb29
    // now, increment the numStudents because you
    // successfully check one birthday
  }

  public String displayOldestBirthdate() {
    // *** implement this method definition ***
    // you simply return a String of your oldestDate
    // you need to look at the example about SimpleDateFormat
  }


  public void writeOutcome() {
    // *** implement this method definition ***
    // display the total student number you have checked
    // display the total student number that have birthday
    // matched to your pre-defined birthday
    // display the oldest birthday date
  }


  // implement any other methods you want (i.e. readDate(), etc.)
}

i know i have long way to learn and it sucks that this is due tomorrow.
im sorry i wouldnt be able to do what you are telling me to do.
but here is an update to my program.
i manage to out the birthdate of the oldest student but it is giving me the wrong birth date.

import java.util.Scanner;
public class StudentBirthdate
{
        public static void main (String[] args)
    {
        Date student = new Date();
        Date base = new Date (02, 29);
        Date oldestStudent = new Date(12, 13, 9999);
        student.readData();
        while (!(student.getStudentId().equals("000")))
        {
            student.dataValid(student);
            if (base.ckBirthDate(student))
                    student.updateBirthDateTotal();
            if (oldestStudent.ckOldestBirthDate(student))
                    oldestStudent = student;
            student.formatMonth();
            student.writeStudentData(student);
            student.readData();
            student.totalStudents();
        }
        student.writeOutcomes();
        student.writeOldest(oldestStudent);
    }
}



import java.util.Scanner;
public class Date
{
    private String studentId;
    private int month;
    private int day;
    private int year;
    private static int totalStudents;
    private static int birthDateTotal;
    private String formattedMonth;
    private static Date oldestStudent;

    public static Date getOldestStudent()
    {
      return oldestStudent;
    }
        public Date()
        {}
        public Date (int m, int d)
        {
            month = m;
            day = d;
         }
        public Date (int m, int d, int y)
        {
            month = m;
            day = d;
            year = y;
        }
        public int getMonth()
        {
            return month;
        }
        public void setMonth(int m)
        {
                month = m;
        }
        public int getDay()
        {
            return day;
        }
        public void setDay(int d)
        {
                day = d;
        }
        public int getYear()
        {
            return year;
        }
        public void setYear(int y)
        {
                year = y;
        }
        public String getStudentId()
        {
            return studentId;
        }

        public void readData()
            {
                Scanner input = new Scanner(System.in);
                System.out.print("Enter a 3-digit student id:");
                studentId = input.next();
                    if(studentId.equals("000")) return;
                System.out.print("Enter month of birth date: ");
                month = input.nextInt();
                System.out.print("Enter day of birth date: ");
                day = input.nextInt();
                System.out.print("Enter year of birth date: ");
                year = input.nextInt();
         }

         public boolean dataValid (Date Student)
                {
                    boolean validate = true;
                    if ((month < 01)||(month > 12))
                    {
                        validate = false;
                        System.out.println("Month must be b/w the range 01-12 inclusive.");
                    }
                    if ((day < 01) || (day > 31))
                    {
                        validate = false;
                        System.out.println("Day must be b/w the range 01-31 inclusive.");
                    }
                    if ((year < 1900) || (year > 1999))
                    {
                        validate = false;
                        System.out.println("Year must be b/w the range 1900-1999 inclusive.");
                    }
                    return validate;
        }
            public void totalStudents()
            {
                totalStudents++;
            }

            public void updateBirthDateTotal()
            {
                birthDateTotal++;
            }

            public boolean ckBirthDate(Date stud)
            {
                    return((month == stud.month) && (day== stud.day))?true:false;
            }


            public void formatMonth()
                    {
                        switch (month)
                            {
                                case 1: formattedMonth = "January";
                                            break;
                                case 2: formattedMonth = "February";
                                            break;
                                case 3: formattedMonth = "March";
                                            break;
                                case 4: formattedMonth = "April";
                                            break;
                                case 5: formattedMonth = "May";
                                            break;
                                case 6: formattedMonth = "June";
                                            break;
                                case 7: formattedMonth = "July";
                                            break;
                                case 8: formattedMonth = "August";
                                            break;
                                case 9: formattedMonth = "September";
                                            break;
                                case 10:formattedMonth = "October";
                                            break;
                                case 11:formattedMonth = "November";
                                            break;
                                case 12:formattedMonth = "Decemember";
                            }
                    }
            public static void writeStudentData(Date Student)
            {
                System.out.println("Student Id: " + Student.studentId);
                System.out.println("Birth Date: " + Student.formattedMonth + Student.day + "," + Student.year);
            }
            public static void writeOutcomes()
            {
                System.out.println(totalStudents + "students were processed.");
                System.out.println(birthDateTotal + "students had a February 29th birth date.");


            }
            public static void writeOldest(Date oldestStudent)
            {
                System.out.println(oldestStudent + "is the birth date of the oldest student");
            }
                            public boolean ckOldestBirthDate(Date Student)
                                {
                                    boolean birthDate = false;
                                    if (Student.getYear() < this.year)
                                        birthDate = true;
                                    else if (Student.getYear() == this.year)
                                        if (Student.getMonth() < this.month)
                                            birthDate = true;
                                        else if (Student.getMonth() == this.month)
                                            if (Student.getDay() < this.day)
                                                birthDate = true;
                                            else
                                                birthDate = false;
                                        else
                                            birthDate = false;
                                    else
                                        birthDate = false;
                                    return birthDate;
                    }
                    public String toString()
                    {
                        return String.format("%d/%d/%d", month, day, year);
                    }

        }
   public static void writeOldest(Date oldestStudent)
            {
                System.out.println(oldestStudent + "is the birth date of the oldest student");
            }   

printing oldestStudent won't print a Date, it'll call the toString method of Date.

your new name for the class 'Date' makes no sense at all. Profile may not have been the best one chose, but at least it made sense.

haven't gone through the entire method, but my guess, you are checking wrong.

try this:

if (!oldestStudent.ckOldestBirthDate(student))
                    oldestStudent = student;

instead of this:

if (oldestStudent.ckOldestBirthDate(student))
                    oldestStudent = student;

it gave me null13, 9999 is the birthdate of the oldest student

.... don't know which code you are running, but either you are not running the code you posted here, or you are not using it the way you should be using it.

I tested the code you posted (without my change) and it seems to be working just fine

it is working just fine but it is giving me the birthdate when i print "oldestStudent"

for example...

studentId: 111
Birth Date: february29,1990

studentId: 222
Birth Date: December13,1991

studentId: 333
Birth Date: June12,1993

Instead of printing february29, 1990 as the oldest birthdate
it is printing the last student that i have entered which is the
studentId: 333
Birth Date: June12, 1993

it is giving me the wrong birthdate when i print "oldestStudent"*

ok ... you write an awfull lot of code, for very little functionality.
I'll re-write parts of it, to show you how (much) easier it can be.

I'm a bit at a loss here ... I have been refactoring your code a bit, and have been testing with the numbers you posted.
you don't really seem to grasp what 'static' means, or how you should use it, and for some reason I haven't figured out yet, your oldestStudent variable is being overwritten each time I enter a new one (even though I've verified the re-assigning of the variable doesn't run.

import java.util.Scanner;
public class Date
{

       public static void main (String[] args)
    {
        Date student = new Date(0,0);
        Date base = new Date (02, 29);
        student.readData();
        while (!(student.getStudentId().equals("000")))
        {
            student.dataValid(student);
            student.totalStudents();
            if (base.ckBirthDate(student))
                    student.updateBirthDateTotal();
            if (oldestStudent == null || student.checkOlderBirthDate()){
                    oldestStudent = student;
                    System.out.println("overwrite");
            }else{
                System.out.println("The oldestStudent REMAINS - " + student.checkOlderBirthDate());
                System.out.println(oldestStudent);
            }
            student.formatMonth();
            student.writeStudentData();
            student.readData();
        }
        writeOutcomes();
        writeOldest();
    }

    private String studentId, formattedMonth;
    private int month, day, year;
    private static int totalStudents;
    private static int birthDateTotal;
    private static Date oldestStudent;

    public Date (int m, int d)
        {
            month = m;
            day = d;
         }
        public Date (int m, int d, int y)
        {
            month = m;
            day = d;
            year = y;
        }
        public int getMonth()
        {
            return month;
        }
        public void setMonth(int m)
        {
                month = m;
        }
        public int getDay()
        {
            return day;
        }
        public void setDay(int d)
        {
                day = d;
        }
        public int getYear()
        {
            return year;
        }
        public void setYear(int y)
        {
                year = y;
        }
        public String getStudentId()
        {
            return studentId;
        }
        public void readData()
            {
                Scanner input = new Scanner(System.in);
                System.out.print("Enter a 3-digit student id:");
                studentId = input.next();
                    if(studentId.equals("000")) return;
                System.out.print("Enter month of birth date: ");
                month = input.nextInt();
                System.out.print("Enter day of birth date: ");
                day = input.nextInt();
                System.out.print("Enter year of birth date: ");
                year = input.nextInt();
         }
         public boolean dataValid (Date Student)
                {
                    if (((month < 01)||(month > 12)) || ((day < 01) || (day > 31)) || ((year < 1900) || (year > 1999)))
                    {
                        System.out.println("Input must be valid.");
                        return false;
                    }
                    return true;
        }
            public void totalStudents()
            {
                totalStudents++;
            }
            public void updateBirthDateTotal()
            {
                birthDateTotal++;
            }
            public boolean ckBirthDate(Date stud)
            {
                    return((month == stud.month) && (day== stud.day));
            }

            private final String[] months = {"","January","February","March","April","May","June","July","August","September","October","November","December"};
            public void formatMonth(){
                        formattedMonth = months[month];
            }
            public void writeStudentData()
            {
                System.out.println("Student Id: " + this.studentId);
                System.out.println("Birth Date: " + this.formattedMonth + " " + this.day + "," + this.year);
            }
            public static void writeOutcomes()
            {
                System.out.println(totalStudents + "students were processed.");
                System.out.println(birthDateTotal + "students had a February 29th birth date.");
            }
            public static void writeOldest()
            {
                System.out.println(oldestStudent + " is the birth date of the oldest student");
            }

            public boolean checkOlderBirthDate(){
                boolean older = false;
                if (oldestStudent.getYear() > this.year)
                    older = true;
                else if (oldestStudent.getYear() == this.year)
                    if (oldestStudent.getMonth() > this.month)
                        older = true;
                    else if (oldestStudent.getMonth() == this.month)
                        if (oldestStudent.getDay() > this.day)
                            older = true;
                return older;
            }

            @Override
            public String toString()
            {
                return String.format("%d/%d/%d", month, day, year);
            }
        }
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.