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

I\'d like to write a program that just displays song lyrics. It should be writte

ID: 3628471 • Letter: I

Question

I'd like to write a program that just displays song lyrics. It should be written in Java and utilize println statements. Part of what i want to do is to reoraganize the structure and redundancy of the lyrics and improve the code using static methods.

This should be basic Java coding, so please refrain from using loops.

Here are the lyrics:

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

On the 2nd day of "Xmas", my true love sent to me
two turtle doves, and
a partridge in a pear tree.

On the 3rd day of "Xmas", my true love sent to me
three French hens,
two turtle doves, and
a partridge in a pear tree.

On the 4th day of "Xmas", my true love sent to me
four calling birds,
three French hens,
two turtle doves, and
a partridge in a pear tree.

On the 5th day of "Xmas", my true love sent to me
five golden rings,
four calling birds,
three French hens,
two turtle doves, and
a partridge in a pear tree.

On the 6th day of "Xmas", my true love sent 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.

*End of lyrics*

It should look exactly like that, including spacing, capitalization and punctuation.

Guidelines:
1. Please no println statements in the main method. The exception is using println to print blank lines.

2. Please have a method for each of the six verses of the song to print that verse's entire contents.

3. please avoid simple redundancy. for example "a partridge in a pair tree" should be utilize only one println statement.

4. For lines that are similar but not exact (ex: on the 1st day of "Xmas"... , and on the 2nd day of "Xmas"...) does not have to be treated as redundant.

5. please no mathematical expression, print, or loops in the coding. println is acceptable.

Thanks for your help. i appreciate the time.

Explanation / Answer

import static java.lang.System.*;

class Test
{
public static void main(String[] args)
{
// print all 6 verses
printFirstLine("1st");
printGift1();
printFirstLine("2nd");
printGift2();
printFirstLine("3rd");
printGift3();
printFirstLine("4th");
printGift4();
printFirstLine("5th");
printGift5();
printFirstLine("6th");
printGift6();
}
public static void printFirstLine(String number)
{
out.println("On the "+number+" day of "Xmas", my true love sent to me");
}
public static void printGift1()
{
out.println("a partridge in a pear tree. ");
}

public static void printGift2()
{
out.println("two turtle doves, and");
// every time we print the 2nd gift, we print the 1st
printGift1();
}
public static void printGift3()
{
out.println("three French hens,");
printGift2();
}
public static void printGift4()
{
out.println("four calling birds,");
printGift3();
}
public static void printGift5()
{
out.println("five golden rings,");
printGift4();
}
public static void printGift6()
{
out.println("six geese a-laying,");
printGift5();
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote