Question: JAVA Write a Java Application that uses repitition and switch statements to print the song The Twelve Days of Christmas. One switch statement should be

JAVA

Write a Java Application that uses repitition and switch statements to print the song "The Twelve Days of Christmas." One switch statement should be used to print the day (i.e. "first", "second", etc.) A separate switch statement should be used to print the remainder of each verse. Visit the Web site www.12days.com/library/carols/12daysofxmas.htm for the complete lyrics of the song.

The Console Output

 Twelve Days of Christmas On the first day of Christmas my true love sent to me: A Partridge in a Pear Tree On the second day of Christmas my true love sent to me: Two Turtle Doves and a Partridge in a Pear Tree On the third day of Christmas ... On the twelfth day of Christmas my true love sent to me: Twelve Drummers Drumming Eleven Pipes Piping Ten Lords a Leaping Nine Ladies Dancing Eight Maids a Milking Seven Swans a Swimming Six Geese a Laying Five Golden Rings Four Calling Birds Three French Hens Two Turtle Doves and a Partridge in a Pear Tree 

Programmer Notes

  • Write and document your program per class coding conventions. Name your class as Assign5.
  • Your program should have a counter-controlled iteration, from 1 to 12, and in it's body, two switch statements.
  • The first switch statement should use break.
  • In the second switch statement, the cases are ordered 12 to 1, and there is no break. Use conditional operator (?:) to output "A" or "and a" depending on if it is the first day or not.

-IF POSSIBLE

Write a JavaFX GUI program to show the song in a text area with a scroll bar instead of in the console.

Hint:

  • Make sure your Assign5.java calls System.out.print() only once. To achieve that:
    • Create a local variable String output = "";
    • Replace all System.out.print("..."); with output += "...";
    • At the end, call System.out.print(output);
  • Copy codes from Assign5 into the method start(). Then edit the generated codes:
    // Copy from Assign5 String output = "\tTwelve Days of Christmas "; for(int day = 1; day  

Please show two codes, the original and the edited Java FX GUI

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!