i need to answer this Question but i can't do it probably

i need to answer this Question but i can't do it probably

use the web to locate the lyrics to the traditional song"The Twelve Days of Christmas" the song contains a list of gifts received for the holiday.the list is cumulative so that as each "day" passes, a new verse contains all the words of the previous verse, plus a new item. write an application that displays the words to the song starting with any day the user enters.(Hint: Use a switch statement with cases in descending day order and without any break statements so that the lyrics for any day repeat all the lyrics for previous days.) save the file as TwelveDays.java

View Answers

February 17, 2011 at 4:07 PM

Java Twelve day of Christmas

public class TwelveDays
{
    public static void main(String[] args)
    {
        System.out.print("Twelve Days of Christmas\n\n");
        int index;

        String ordinal_numbers[] = { "first", "second",   "third",  "fourth", "fifth",  "sixth",  "seventh",  "eighth",  "ninth", "tenth", "eleventh",  "twelfth"};

        for(index = 1; index <= 12; ++index)
        {
            System.out.print("On the " + ordinal_numbers[index-1]+ " day of Christmas,\n");
            switch(index)
            {
                case 12:
                    System.out.println("Twelve Drummers Drumming");

                case 11:
                    System.out.println("Eleven Pipers Piping");

                case 10:
                    System.out.println("Ten Lords a Leaping");

                case 9:
                    System.out.println("Nine Ladies Dancing");

                case 8:
                    System.out.println("Eight Maids a Milking");

                case 7:
                    System.out.println("Seven Swans a Swimming");

                case 6:
                    System.out.println("Six Geese a Laying");

                case 5:
                    System.out.println("Five Golden Rings");

                case 4:
                    System.out.println("Four Calling Birds");

                case 3:
                    System.out.println("Three French Hens");

                case 2:
                    System.out.println("Two Turtle Doves");

                case 1:
                    if(index == 0)
                        System.out.print("A Partridge in a Pear Tree.\n\n");
                    else
                        System.out.print("and a Partridge in a Pear Tree.\n\n");
                    break;
                default:
                    System.out.print("Internal Error.");
                    System.exit(1);
            }
        }                                     
    }
}

February 17, 2011 at 9:48 PM

thanx very much









Related Tutorials/Questions & Answers:
i need to answer this Question but i can't do it probably
i need to answer this Question but i can't do it probably   use the web to locate the lyrics to the traditional song"The Twelve Days of Christmas" the song contains a list of gifts received for the holiday.the list is cumulative
i cNT GET ANSWER FOR THIS QUESTION
i cNT GET ANSWER FOR THIS QUESTION  The roots of the quadratic equation ax2+bx+c=0, aïâ??¹0 are given by the following formula: x=(-bÃ?±âË?Å¡(b^2-4ac))/2a In this formula. The term b2-4ac is called
Advertisements
how do i solve this question?
how do i solve this question?  1.Define a class named Circle with the following properties: a) An integer data field named radius with protected access modifier, and a String data field named colour with private access modifier
what is java and why do i need it?
what is java and why do i need it?  Hi, Please tell me what is Java and why do i need it? Is it free to download? Also explain me how to write and test my first Java Application? What is the configuration or system requirement
Do I need math for data science?
Do I need math for data science?  Hi, I am beginner in Data Science and machine learning field. I am searching for the tutorials to learn: Do I... so that I can learn the topic "Do I need math for data science?"
What skills do I need for machine learning?
What skills do I need for machine learning?  Hi, I am beginner... to learn: What skills do I need for machine learning? Try to provide me good examples or tutorials links so that I can learn the topic "What skills do I need
What skills do I need to be a data analyst?
What skills do I need to be a data analyst?  Hi, I am beginner... to learn: What skills do I need to be a data analyst? Try to provide me good examples or tutorials links so that I can learn the topic "What skills do I need
What do I need to do to use a MSSQL-Server with Web-Harvester?
What do I need to do to use a MSSQL-Server with Web-Harvester?  What do I need to do to use a MSSQL-Server with Web-Harvester
PureStack question---i dont know how to do this
PureStack question---i dont know how to do this  Write a stack class ArrayStack.java implements PureStack interface that reads in strings from... the queue g. H and I join the queue h. G leaves the queue i. H and I leave
PureStack question---i dont know how to do this
PureStack question---i dont know how to do this  Write a stack class ArrayStack.java implements PureStack interface that reads in strings from... the queue g. H and I join the queue h. G leaves the queue i. H and I leave
This is what i need in this Question - Java Beginners
This is what i need in this Question  You are to choose between two... array. so i need your help to know is it correct or wrong Thank you... explaination with out coding In my understanding I choose the non-empty array
Java web development, what skills do I need?
Java web development, what skills do I need?  Java web development, what skills do I need
Java web development, what skills do I need?
Java web development, what skills do I need?  Java web development, what skills do I need
I really need a tutor for Java program that has to do with multithreading and gui!
I really need a tutor for Java program that has to do with multithreading and gui!  I am looking for a Tutor to help me with a Java program, specially GUI and multithreading. If you can tutor, please email me
Do I need a Masters/PhD to become a data scientist?
Do I need a Masters/PhD to become a data scientist?  Hi, I am... for the tutorials to learn: Do I need a Masters/PhD to become a data scientist? Try to provide me good examples or tutorials links so that I can learn the topic "Do I
i have a problem to do this question...pls help me..
i have a problem to do this question...pls help me..  Write a program... reversedNumber = 0; for (int i = 0; i <= num; i...; reversedNumber = reversedNumber * 10 + r; i = 0
i want to do a project using jsp and servlet....What are all the materials i need to study
i want to do a project using jsp and servlet....What are all the materials i need to study   i want to do a project using jsp and servlet....What are all the materials i need to study ?   Please visit the following
hello there i need help
hello there i need help  : i need to do a program like this: Automatic Teller Machine [B] Balance [D] Deposit [W] Withdrawal [Q] Quit select you... me with the codes and please explain to me how it works. i only need to use
I need an example of sessionfactory
I need an example of sessionfactory  Hi, I need an example of session factory in hibernate. If you can provide me one with, that would be great...Thanks
Add color to background but I can't labels or textfields
Add color to background but I can't labels or textfields  Please help...); f.setVisible(true); } }");   For label you need to create and initialize the JLabel class object and add it to container. Inorder to do that you
i need project
i need project  can u send online shoppin project 2 my mailid.   Please visit the following links: Struts2 Shopping cart JSP-Servlet Shopping cart
i need a help in this please
i need a help in this please  The factorial of a nonnegative integer n is written n! (pronounced â?? n factorialâ??) and is defined as follows: n!=n...=input.nextInt(); long num=m; for(int i=m;i>1;i
I have need to help
I have need to help  Write a program that, for four points A, B, C and P, draws a triangle formed by ABC and a small cross showing the position of P; and displays a line of text indicating which of the following three cases
How do I upgrade mysql?
How do I upgrade mysql?  How do I upgrade mysql
How can I do it? .click();
How can I do it? .click();  I have a very unusual problem. I want...("a"); x.click(); </script> So it's click on an element witch one Id's is "a", but I want that it make mouseup in this element. How can I do it, because if I write
I need Spring 2.5 example.
I need Spring 2.5 example.  Hello, I am looking forward to learn Spring framework and hence I need Spring 2.5 and Spring 3.0 example.. Thanks
i need help - Development process
i need help  hello, i need help regarding this program. public... the result in to the files,if i want to do this i must make my program running...()); } } } it is printing the result of ping in to a file,but if i want
I really need help with this assignment question Please help me out Please
I really need help with this assignment question Please help me out Please  * Description* You are hired to develop a laptop inventory information... in MySQL. For this purpose you will need to use the sheridancollege database we
This is what i need - Java Beginners
. for this question i need just : one function can read string like (I like...This is what i need  Implement a standalone procedure to read in a file containing words and white space and produce a compressed version of the file
i need help - Development process
i need help  hello, i need help regarding this program. this program... IPAddress on command line, but i want to take it dynamically and it must store the result of ping in to a file . can anyone guide me how to do it please
I need to develop a gui like this
I need to develop a gui like this  Hai Friends, I need to develop such a menu in my gui programs. The gui contains 1 text field.whenever the text... please help me   sorry goes through this link I need to develop like
How do I compile the registration form?
How do I compile the registration form?  How do I compile the registration form as stated at the bottom of the following page (URL is below). Do I need ANT? If so, please give instructions. I am a student. http
please i want someone to answer me pleeeeeeeeeeeeease...
please i want someone to answer me pleeeeeeeeeeeeease...    Write a JAVA program using 2D array to auto-grade exams. For a class of N students, your... answer key as Final Array in your program.( using 2D array
How do I start machine learning with Python? What should I do if I am a beginner?
How do I start machine learning with Python? What should I do if I am... am searching for the tutorials to learn: How do I start machine learning with Python? What should I do if I am a beginner? Try to provide me good examples
help i want it now the answer pleas...
help i want it now the answer pleas...  write a program that will display the exactly output as below: Hints: declare and initialize value of array in double type.Read and write all elements of array.perform the multiply
i need program or code for this program
i need program or code for this program  out should be in this form 1 2 3 4 5 6 3 5 7 9 11 8 12 16 20 20 28 36 48 64 112
I need Oracle connector jar file. where will i download?
I need Oracle connector jar file. where will i download?  I need Oracle connector jar file. where will i download
i need help to solve this problem
i need help to solve this problem  Write a stack class ArrayStack.java implements PureStack interface that reads in strings from standard input.... H and I join the queue h. G leaves the queue i. H and I leave the queue
I am new to ML/AI. Where do I start learning?
I am new to ML/AI. Where do I start learning?  Hi, I am beginner... to learn: I am new to ML/AI. Where do I start learning? Try to provide me good.... Where do I start learning?". Also tell me which is the good training
how do i solve this problem?
how do i solve this problem?  Define a class named Circle with the following properties: List item An integer data field named radius with protected access modifier, and a String data field named colour with private access
i need help plz .... Quickly
i need help plz .... Quickly   how can i count how many numbers enterd by the user so the output would be like this Total number of Scores = .... this is my code :- (adsbygoogle = window.adsbygoogle || []).push
How do I decompile Java class files?
How do I decompile Java class files?  How do I decompile Java class files
How do I initialize a byte array in Java?
How do I initialize a byte array in Java?  How do I initialize a byte array in Java
How do I compare strings in Java?
How do I compare strings in Java?  How do I compare strings in Java
Dear Sir I need to join u
Dear Sir I need to join u  Dear Sir i am santosh Rai from Saudi Arabia please make me understood how to join u and i have one question i want to working with you what is ur process for working with u please send me
How do i do the coding for 'leaving a comment' in java
How do i do the coding for 'leaving a comment' in java  i am designing a webpage.In my webpage i want to add the option of adding a comment by the readers of the page.how do i do
regular expression expalanation i need
regular expression expalanation i need  hi......... here is my code could explain it <html> <script language = "Javascript"> function checkEmail() { if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test
how do i begin a two dimensional array?
how do i begin a two dimensional array?  I'm new to java programming and need to create a two dimensional array that enters exactly what is entered in the first dimension and then the first non-white space character of what
How do I learn Python data science?
How do I learn Python data science?  Hi, I am beginner in Data... do I learn Python data science? Try to provide me good examples or tutorials links so that I can learn the topic "How do I learn Python data science
How can I do data science course?
How can I do data science course?  Hi, I am beginner in Data Science... can I do data science course? Try to provide me good examples or tutorials links so that I can learn the topic "How can I do data science course?"

Ads