I've been trying to build a java program to display the date in a MM/DD/YYYY format with constructors to link the return data, this is the initial sequence and was wondering about my get and set statement; and their format.

// Date class with a constructor to
// to initialize instance variable to display date.
import java.util.Scanner;


public class Date 
{
    private int month; // instance variable that stores the month variable
    private int day;// instance variable that stores the day variable
    private int year;// instance variable that stores the year variable

   // constructor displays date in MM/DD/YYYY format   
    public Date(int date) 
   {
      // 
        date = displayDate; 
   } // end Date constructor
   // method  to set the date
   public void setMonth(int Month variable)
   {
    month = Month variable;
    '}
    public void setDay(int Day variable)
   {
    day = Day variable;
    '}
    public void setYear(int Year variable)
   {
    year = Year variable;
    '}
    //end method setDate

        //method to retrieve Date
            public int getMonth()
    {
        return month;
    }
    public int getDay()
    {
        return day;
    }
    public int getYear()
    {
        return year;
    }
    // end method getDate

    //display Date
    public void displayDate (date)

        System.out.printf(MM/DD/YYYY)
   }
    }//end class Date

NewToThis

Good jCoke,

System.out.println(mm + "/" + dd + "/" + yy);
//or
System.out.printf("\n%d/%d/%d",mm,dd,yy);

You should at least try to compile this coded and fix any compile errors.

I have worked out most of the bugs, but I keep getting a expected error with the following statement:

System.out.printf("/n%d/%d/%d",mm,dd,yy)

What did it expect? (maybe a ; at the end?)

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.