been working on this for 2 days and can't figure out what I am doing wrong. We are suppose to input a day and the days gifts are to be in the output. When I put in my day it starts with the correct day but then loops through all twelve cases. I have break statement's but to no avail. Any help or ideas would be apimport
java.util.Scanner;//program uses scanner
public class ChristmasSong
{
//shows user Christmas gifts based on day the user inputs.
public static void main(String[] args)
{
Scanner input = new Scanner ( System.in );
int day; //used to select day to display gifts
System.out.println ( "Enter the Day for the gifts you would like " +
"to see (1-12)" );
day = input.nextInt();
if ( day < 1 )//check to see that a valid day is picked
{
System.out.println ( "Invalid Day: please try again- select between" +
"1 and 12" );
}//end if
else if ( day > 12)//check to see that a valid day is picked
{
System.out.println ( "Invalid Day: please try again- select between" +
"1 and 12");
}//end else if
System.out. print ( "One the " );
while ( day >0 )
{
switch (day )//day based on user input
{
case 1:
System.out.print ( "first day of Christmas, \nmy true love " +
"gave to me\n A partidge in a pear tree\n\n\n" );
day--;
break;
case 2:
System.out.print ( "second day of Christmas, \nmy true love" +
" gave to me\nTwo turtle doves \nand \nA " +
"partridge in a pear tree\n\n\n" );
day--;
break;
case 3:
System.out.print ( "third day of Christmas, \nmy true love" +
" gave to me\nThree french hens,\n" +
"Two turtle doves \nand \nA " +
"partridge in a pear tree\n\n\n" );
day--;
break;
case 4:
System.out.print ( "forth day of Christmas, \nmy true love" +
" gave to me\nFour calling birds,\n" +
"Three french hens,\n" +
"Two turtle doves \nand \nA " +
"partridge in a pear tree\n\n\n" );
day--;
break;
case 5:
System.out.print ( "fifth day of Christmas, \nmy true love" +
" gave to me\nFive golden rings\n" +
"Four calling birds,\n" +
"Three french hens,\n" +
"Two turtle doves \nand \nA " +
"partridge in a pear tree\n\n\n" );
day--;
break;
case 6:
System.out.print ( "sixth day of Christmas, \nmy true love" +
" gave to me\nSix geese a-laying,\n" +
"Five golden rings\n" +
"Four calling birds,\n" +
"Three french hens,\n" +
"Two turtle doves \nand \nA " +
"partridge in a pear tree\n\n\n" );
day--;
break;
case 7:
System.out.print ( "seventh day of Christmas, \nmy true love" +
" gave to me\nSeven swans a-swimming,\n" +
"Six geese a-laying,\n" +
"Five golden rings\n" +
"Four calling birds,\n" +
"Three french hens,\n" +
"Two turtle doves \nand \nA " +
"partridge in a pear tree\n\n\n" );
day--;
break;
case 8:
System.out.print ( "eighth day of Christmas, \nmy true love" +
" gave to me\nEight maids a-milking,\n" +
"Seven swans a-swimming,\n" +
"Six geese a-laying,\n" +
"Five golden rings\n" +
"Four calling birds,\n" +
"Three french hens,\n" +
"Two turtle doves \nand \nA " +
"partridge in a pear tree\n\n\n" );
day--;
break;
case 9:
System.out.print ( "ninth day of Christmas, \nmy true love" +
" gave to me\nNine ladies dancing,\n" +
"Eight maids a-milking,\n" +
"Seven swans a-swimming,\n" +
"Six geese a-laying,\n" +
"Five golden rings\n" +
"Four calling birds,\n" +
"Three french hens,\n" +
"Two turtle doves \nand \nA " +
"partridge in a pear tree\n\n\n" );
day--;
break;
case 10:
System.out.print ( "tenth day of Christmas, \nmy true love" +
" gave to me\nTen lords a-leaping,\n" +
"Nine ladies dancing,\n" +
"Eight maids a-milking,\n" +
"Seven swans a-swimming,\n" +
"Six geese a-laying,\n" +
"Five golden rings\n" +
"Four calling birds,\n" +
"Three french hens,\n" +
"Two turtle doves \nand \nA " +
"partridge in a pear tree\n\n\n" );
day--;
break;
case 11:
System.out.print ( "eleventh day of Christmas, \nmy true love" +
" gave to me\nEleven pipers piping,\n" +
"Ten lords a-leaping,\n" +
"Nine ladies dancing,\n" +
"Eight maids a-milking,\n" +
"Seven swans a-swimming,\n" +
"Six geese a-laying,\n" +
"Five golden rings\n" +
"Four calling birds,\n" +
"Three french hens,\n" +
"Two turtle doves \nand \nA " +
"partridge in a pear tree\n\n\n" );
day--;
break;
case 12:
System.out.print ( "twelfth day of Christmas, \nmy true love" +
" gave to me\nTwelve drummers drumming,\n" +
"Eleven pipers piping,\n" +
"Ten lords a-leaping,\n" +
"Nine ladies dancing,\n" +
"Eight maids a-milking,\n" +
"Seven swans a-swimming,\n" +
"Six geese a-laying,\n" +
"Five golden rings\n" +
"Four calling birds,\n" +
"Three french hens,\n" +
"Two turtle doves \nand \nA " +
"partridge in a pear tree\n\n\n" );
day--;
}//end switch
}//end while
}//end method main
}//end ChristmasSongpreciated. Here is the code.....