Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners i need to answer this Question but i can't do it probably
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


mahamat ali
i need to answer this Question but i can't do it probably
2 Answer(s)      3 years and 8 months ago
Posted in : Java Beginners


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


Advertisement
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
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 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
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
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
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 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
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
How do I upgrade mysql?
How do I upgrade mysql?  How do I upgrade mysql
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 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
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
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 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
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 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
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 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
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
 

 

 

DMCA.com