Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

some one tried to answer this question and the programm did not work. any expert

ID: 3862591 • Letter: S

Question

some one tried to answer this question and the programm did not work. any expert out there ', thanks i appreciate it.

7.11111111 program requirements

As a reminder, you should be including comments in your programs . Comments should be placed periodically throughout your program. Your comments should explain the logic of what you are doing. You do not need to write comments before every line in your program. Instead, you should add comments at the beginning of a section of code to explain what the next few lines are trying to accomplish.

Pay close attention to the directions!! Make absolutely certain that you are doing exactly what the assignment asks you to do. If you don't understand the problem, make sure to ask your instructor or an assistant.

part 1

Begin by creating a new Java project.

Create a new Java class inside your project folder.
The name of the class should be: TwelveDays

Write a java application program that will print the verses of the song The Twelve Days of Christmas to the screen. In this song, each verse adds one additional line of output to the song.

The first verse should print the following:

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

The second verse should print the following:

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

The third verse should print the following:

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

There are a total of 12 verses to the song, and each verse will add one additional line to the song. The final verse should print the following:

On the 12th day of Christmas my true love gave to me
Twelve drummers drumming,
Eleven pipers piping,
Ten lords a leaping,
Nine ladies dancing,
Eight maids a milking,
Seven swans a swimming,
Six geese a laying,
Five golden rings,
Four calling birds,
Three French hens,
Two turtle doves, and
A partridge in a pear tree.

After each verse is printed, ask the user to press "Enter" to continue.This will allow your program to pause after each verse to give the user time to read the verse before moving on to another.
You should NOT ask the user to press "Enter" after the last verse.

Program Restrictions

You CANNOT write tons of print statements to simply print out the entire song.

Your program MUST include a loop. The loop should be designed to repeat exactly 12 times. Each trip through the loop should print one verse to the screen.

Inside the loop, you MUST use a switch statements to control the lines that are printed to the screen.< >For the statement "On the Xth day of Christmas my true love gave to me":Begin by printing "On the X" where X is the value of your loop counter.Next, use a switch statement to print "st" or "nd" or "rd" or "th" to the screen. At this point, depending on the value of the loop counter, this will cause one of the following lines to be printed:
On the 1st
On the 2nd
On the 3rd
On the 4th
etc.
Now, print the rest of the line to the screen:
" day of Christmas my true love gave to me"After the first line has been printed, use another switch statement to control which lines of the verse are printed to the screen. Each case statement is allowed to contain a single println statement so that each case statement is printing a single line of output to the screen.

Hint

Order the cases carefully to avoid using the break statement.

Explanation / Answer

import java.util.Scanner;
public class TwelveDays {
  
  

public static void main(String[] args) {
   
Scanner in = new Scanner(System.in);

String[] arrLyrics;
arrLyrics = new String[13];
arrLyrics[0] = "On the % day of Christmas, my true love gave to me";
arrLyrics[1] = "A partridge in a pear tree.";
arrLyrics[2] = "Two turtle doves, and";
arrLyrics[3] = "Three French hens,";
arrLyrics[4] = "Four calling birds,";
arrLyrics[5] = "Five golden rings,";
arrLyrics[6] = "Six geese a laying,";
arrLyrics[7] = "Seven swans a swimming,";
arrLyrics[8] = "Eight maids a milking,";
arrLyrics[9] = "Nine ladies dancing,";
arrLyrics[10] = "Ten lords a leaping,";
arrLyrics[11] = "Eleven pipers piping,";
arrLyrics[12] = "Twelve drummers drumming,";

int loopAmount = 13;

for (int i=1; i<loopAmount; i++){
String day;
String dailyLyric;

if(i==1){
day = "st";
} else if(i==2){
day = "nd";
} else if(i==3){
day = "ed";
} else {
day = "th";
}

dailyLyric = arrLyrics[0].replace("%", i + day);
System.out.println(dailyLyric);


switch(i){
case 12:
System.out.println(arrLyrics[12]);
  
case 11:
System.out.println(arrLyrics[11]);
case 10:
System.out.println(arrLyrics[10]);
case 9:
System.out.println(arrLyrics[9]);
case 8:
System.out.println(arrLyrics[8]);
case 7:
System.out.println(arrLyrics[7]);
case 6:
System.out.println(arrLyrics[6]);
case 5:
System.out.println(arrLyrics[5]);
case 4:
System.out.println(arrLyrics[4]);
case 3:
System.out.println(arrLyrics[3]);
case 2:
System.out.println(arrLyrics[2]);
case 1:
System.out.println(arrLyrics[1]);
System.out.println();
if(i!=12)
{
System.out.print("Press enter to continue . . . ");
     in.nextLine();
}
else
{
    System.exit(0);
}
   
break;

}

}

}

}
  

when it is run in netbeans....

output is :

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

Press enter to continue . . .
On the 2nd day of Christmas, my true love gave to me
Two turtle doves, and
A partridge in a pear tree.

Press enter to continue . . .
On the 3ed day of Christmas, my true love gave to me
Three French hens,
Two turtle doves, and
A partridge in a pear tree.

Press enter to continue . . .
On the 4th day of Christmas, my true love gave to me
Four calling birds,
Three French hens,
Two turtle doves, and
A partridge in a pear tree.

Press enter to continue . . .
On the 5th day of Christmas, my true love gave to me
Five golden rings,
Four calling birds,
Three French hens,
Two turtle doves, and
A partridge in a pear tree.

Press enter to continue . . .
On the 6th day of Christmas, my true love gave to me
Six geese a laying,
Five golden rings,
Four calling birds,
Three French hens,
Two turtle doves, and
A partridge in a pear tree.

Press enter to continue . . .
On the 7th day of Christmas, my true love gave to me
Seven swans a swimming,
Six geese a laying,
Five golden rings,
Four calling birds,
Three French hens,
Two turtle doves, and
A partridge in a pear tree.

Press enter to continue . . .
On the 8th day of Christmas, my true love gave to me
Eight maids a milking,
Seven swans a swimming,
Six geese a laying,
Five golden rings,
Four calling birds,
Three French hens,
Two turtle doves, and
A partridge in a pear tree.

Press enter to continue . . .
On the 9th day of Christmas, my true love gave to me
Nine ladies dancing,
Eight maids a milking,
Seven swans a swimming,
Six geese a laying,
Five golden rings,
Four calling birds,
Three French hens,
Two turtle doves, and
A partridge in a pear tree.

Press enter to continue . . .
On the 10th day of Christmas, my true love gave to me
Ten lords a leaping,
Nine ladies dancing,
Eight maids a milking,
Seven swans a swimming,
Six geese a laying,
Five golden rings,
Four calling birds,
Three French hens,
Two turtle doves, and
A partridge in a pear tree.

Press enter to continue . . .
On the 11th day of Christmas, my true love gave to me
Eleven pipers piping,
Ten lords a leaping,
Nine ladies dancing,
Eight maids a milking,
Seven swans a swimming,
Six geese a laying,
Five golden rings,
Four calling birds,
Three French hens,
Two turtle doves, and
A partridge in a pear tree.

Press enter to continue . . .
On the 12th day of Christmas, my true love gave to me
Twelve drummers drumming,
Eleven pipers piping,
Ten lords a leaping,
Nine ladies dancing,
Eight maids a milking,
Seven swans a swimming,
Six geese a laying,
Five golden rings,
Four calling birds,
Three French hens,
Two turtle doves, and
A partridge in a pear tree.

BUILD SUCCESSFUL (total time: 20 seconds)