Beach Runner
beats on hood
The Twelve Days of Christmas
import javax.swing.*;
public class twelveDaysOfChristmas
{
public static void main( String args [] )
{
JTextArea outputArea = new JTextArea( 40, 50 );
JScrollPane scroller = new JScrollPane( outputArea );
int day;
String output = " ";
for ( day = 1; day <= 12 ; day ++ ) {
output += "On the ";
switch ( day )
{
case 1
utput +="first";break;
case 2
utput +="second";break;
case 3
utput +="third";break;
case 4
utput +="fourth";break;
case 5
utput +="fifth";break;
case 6
utput +="sixth";break;
case 7
utput +="seventh";break;
case 8
utput +="eighth";break;
case 9
utput +="ninth";break;
case 10
utput +="tenth";break;
case 11
utput +="eleventh";break;
case 12
utput +="twelfth";break;
}
output += " day of Chrismas my true love gave to me\n";
switch ( day )
{
case 12
utput +="Twelve drummers drumming\n";
case 11
utput +="Eleven pipers piping\n";
case 10
utput +="Ten lords a-leaping\n";
case 9
utput +="Nine ladies dancing\n";
case 8
utput +="Eight maids a-milking\n";
case 7
utput +="Seven swans a-swimming\n";
case 6
utput +="Six geese a-laying\n";
case 5
utput +="FIVE GOLDEN RINGS\n";
case 4
utput +="Four calling birds\n";
case 3
utput +="Three French hens\n";
case 2
utput +="Two turtle doves\n";
case 1:if(day == 1)output += "A partridge in a pear tree\n";
else output +="And a partridge in a pear tree\n";
}
}
outputArea.setText( output );
JOptionPane.showMessageDialog
(null, scroller, "TwelveDaysOfChristmas",
JOptionPane.PLAIN_MESSAGE );
System.exit( 0 );
}
}
import javax.swing.*;
public class twelveDaysOfChristmas
{
public static void main( String args [] )
{
JTextArea outputArea = new JTextArea( 40, 50 );
JScrollPane scroller = new JScrollPane( outputArea );
int day;
String output = " ";
for ( day = 1; day <= 12 ; day ++ ) {
output += "On the ";
switch ( day )
{
case 1
case 2
case 3
case 4
case 5
case 6
case 7
case 8
case 9
case 10
case 11
case 12
}
output += " day of Chrismas my true love gave to me\n";
switch ( day )
{
case 12
case 11
case 10
case 9
case 8
case 7
case 6
case 5
case 4
case 3
case 2
case 1:if(day == 1)output += "A partridge in a pear tree\n";
else output +="And a partridge in a pear tree\n";
}
}
outputArea.setText( output );
JOptionPane.showMessageDialog
(null, scroller, "TwelveDaysOfChristmas",
JOptionPane.PLAIN_MESSAGE );
System.exit( 0 );
}
}
Last edited:
