Day of Week.

Q17. Design a Java Netbeans 6.5.1 GUI application to find out Day of Week.

Sol:

Create a GUI application as per following screenshot.

Type the following code by double clicking jButton1, button, below the line that says, ‘// TODO add your handling code here’

 

int daynum;

daynum=Integer.parseInt(.getText());

switch(daynum)

{

case 1:

jTextField2.setText(“Day 1 is Sunday”);

break;

case 2:

jTextField2.setText(“Day 2 is Monday”);

break;

case 3:

jTextField2.setText(“Day 3 is Tuesday”);

break;

case 4:

jTextField2.setText(“Day 4 is Wednesday”);

break;

case 5:

jTextField2.setText(“Day 5 is Thursday”);

break;

case 6:

jTextField2.setText(“Day 6 is Friday”);

break;

case 7:

jTextField2.setText(“Day 7 is Saturday”);

break;

default :

jTextField2.setText(“Invalid Day”);

}

}

 

Type the following code by double clicking jButton2, button, below the line that says, ‘// TODO add your handling code here’

jTextField1.setText(“”);

jTextField2.setText(“”);

}

Type the following code by double clicking jButton3, button, below the line that says, ‘// TODO add your handling code here’

System.exit(0);

}

Output:

Leave a Reply

Your email address will not be published. Required fields are marked *