public class Date
{
private int month;
private int day;
private int year;
public Date( int userMonth, int userDay, int userYear )
{
month = userMonth;
day = userDay; // This section is responsible for establishing default values.
year = userYear;
}
public void setMonth( int userMonth )
{
month = userMonth; // This is a set method for month.
}
public int getMonth()
{
return month; // This is a get method for month.
}
public void setDay( int userDay )
{
day = userDay; // This is a set method for day.
}
public int getDay()
{
return day;// This is a get method for day.
}
public void setYear( int userYear )
{
year = userYear; // This is a set method for year.
}
public int getYear()
{
return year; // This is a get method for year.
}
public void displayDate()
{
String Date = String.format( " %d\n/%d\n/%d\n", month, day, year );
}
public void main( String[] args )
{
System.out.print( "Enter the month number: " );
month = input.nextInt();
System.out.print( "Enter the day number: " );
day = input.nextInt();
System.out.print( "Enter the year number: " );
year = input.nextInt();
}
}
Everything seems to be working, except the italicized section. Any suggestions? The purpose of the program is to display the date in this format: 01/29/2012.
Thanks Again!