JAVA CODE

// Date2 program
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;

public class Date2 extends Applet
             implements ActionListener
{
  Label Prompt, Prompt1, Prompt2;
  TextField DayText, MonthText, YearText;
  int Day, Month, Year;

  public void init()
  {
    Prompt  = new Label (" Enter day ");
    add(Prompt);

    DayText = new TextField(3);
    add(DayText);
    DayText.addActionListener(this);

    Prompt1 = new Label (" Enter month ");
    add(Prompt1);
   
    MonthText = new TextField(3);
    add(MonthText);
    MonthText.addActionListener(this);

    Prompt2 = new Label (" Enter year ");
    add(Prompt2);

    YearText = new TextField(4);
    add(YearText);
    YearText.addActionListener(this);
  }

  public void paint( Graphics g )
  {
    if (Day < 1 )                 
    {
       g.drawString("The day can't be zero or negative value", 30, 80);
       g.drawString("Please try again", 30, 100);
    }
    else if (Day > 31)
    {
       g.drawString("It day can't larger than 31", 30, 80);
       g.drawString("Please try again", 30, 100);
    }
    else switch ( Month )
    {
       case 1 : g.drawString("The date is " + Day + " Jan " + Year, 30, 80 );
                break;
       case 2 : g.drawString("The date is " + Day + " Feb " + Year, 30, 80 );
                break;
       case 3 : g.drawString("The date is " + Day + " Mar " + Year, 30, 80 );
                break;
       case 4 : g.drawString("The date is " + Day + " Apr " + Year, 30, 80 );
                break;
       case 5 : g.drawString("The date is " + Day + " May " + Year, 30, 80 );
                break;
       case 6 : g.drawString("The date is " + Day + " Jun " + Year, 30, 80 );
                break;
       case 7 : g.drawString("The date is " + Day + " Jul " + Year, 30, 80 );
                break;
       case 8 : g.drawString("The date is " + Day + " Aug " + Year, 30, 80 );
                break;
       case 9 : g.drawString("The date is " + Day + " Sept " + Year, 30, 80 );
                break;
       case 10: g.drawString("The date is " + Day + " Oct " + Year, 30, 80 );
                break;
       case 11: g.drawString("The date is " + Day + " Nov " + Year, 30, 80 );
                break;
       case 12: g.drawString("The date is " + Day + " Dec " + Year, 30, 80 );
                break;
       default: g.drawString("The month can't smaller than 1 or larger than 12", 30, 90 );
                break;
    }
  }

  public void actionPerformed ( ActionEvent e )
  {
     Day   = Integer.valueOf(DayText.getText()).intValue();
     Month = Integer.valueOf(MonthText.getText()).intValue();
     Year  = Integer.valueOf(YearText.getText()).intValue();
     repaint();
  }
}