Hi i have a bit of code:

On the 1st day of Christmas,
my true love sent to me
A partridge in a pear tree.

On the 2nd day of Christmas,
my true love sent to me
Two turtle doves,
And a partridge in a pear tree.

On the 3rd day of Christmas,
my true love sent to me
Three French hens,
Two turtle doves,
And a partridge in a pear tree.

how would i display it with out methods or arrays to display Each line of the song should only appear once in your code?
I managed so far :

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package christmas;

/**
 *
 * @author Libra
 */
public class Christmas {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {

        for (int i = 1; i <= 3; i++) {
            String output = "On the" + i +" day of Christmas,\n" + "my true love sent to me \n";

            System.out.println(output);
          switch(i)
          {
              case 3: 
                  String line1 = "Three French hens,\n" +
"Two turtle doves,\n" +
"And a partridge in a pear tree. " ;

                  System.out.println(output=line1); 
              case 2: 
                  String line2 = "Two turtle doves,\n" +
"And a partridge in a pear tree. ";
                  System.out.println(output=line2);


          }
        }
    }

}

Remember that a switch case will drop through into the following case unless it has a break;
So you are on the right tracks there except that you don't need lines 27, 28 or 33. If you enter case 3 then it will print 3 french hens then drop through into the next case where it will print 2 turtle doves. Similarly the partridge only needs to be there once, at the end.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.