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

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 6 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 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
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
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
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 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 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 :- import java.util.Scanner; public class SCORES { public
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 compare strings in Java?
How do I compare strings in Java?  How do I compare strings in Java
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 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 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
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
HOW TO I CHANGE THE SWITCH TO IF ELSE OR DO WHILE OR WHILE DO FOR THIS CODING
HOW TO I CHANGE THE SWITCH TO IF ELSE OR DO WHILE OR WHILE DO..."); System.out.println("| q. Quit"); question = console.next().charAt(0...*; import java.lang.*; public class LinkedListv4 { char question; Scanner console
HOW TO I CHANGE THE SWITCH TO IF ELSE OR DO WHILE OR WHILE DO FOR THIS CODING
HOW TO I CHANGE THE SWITCH TO IF ELSE OR DO WHILE OR WHILE DO..."); System.out.println("| q. Quit"); question = console.next().charAt(0...*; import java.lang.*; public class LinkedListv4 { char question; Scanner console
HOW TO I CHANGE THE SWITCH TO IF ELSE OR DO WHILE OR WHILE DO FOR THIS CODING
HOW TO I CHANGE THE SWITCH TO IF ELSE OR DO WHILE OR WHILE DO..."); System.out.println("| q. Quit"); question = console.next().charAt(0...*; import java.lang.*; public class LinkedListv4 { char question; Scanner console
HOW TO I CHANGE THE SWITCH TO IF ELSE OR DO WHILE OR WHILE DO FOR THIS CODING
HOW TO I CHANGE THE SWITCH TO IF ELSE OR DO WHILE OR WHILE DO..."); System.out.println("| q. Quit"); question = console.next().charAt(0...*; import java.lang.*; public class LinkedListv4 { char question; Scanner console
how do i grab the url in php?
how do i grab the url in php?  I want to grab the 'entire' url, including any special characters like & and #, from a site. I then want... # = %23 I tried URL encoding but it only grabs the part until the #, which
How do I generate random number?
How do I generate random number?  In my Java program there is a requirement of generating random numbers between two given numbers. How do I write code for generating the random number? Thanks   Hi
what should i do next?? - Java Beginners
what should i do next??  I know java basics.actully i passed the SCJP exam.Then now i have no idea about what should i do next.I like to come to the web development.I want to know which one i should study first.JSP or servlet
need answer
need answer  Given a phone number, as a string, generate the lettercombinations that are possible based on the telephone keypad's number/letter relationship (ie, 1 is related to no letters, 2 is related to 'a' 'b' 'c', 3
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 write a java program for this??
how do i write a java program for this??  ??Ask the user if they have a dog. If ??yes??, ask the user how old is and compute the dog??s age in human years. Display the output. If ??no?? ask the user their age and compute
Advertisements
 

 

 

DMCA.com