Answered step by step
Verified Expert Solution
Question
1 Approved Answer
public class Lyrics { public static void main ( String [ ] args ) { singDuckSong ( ) ; } private static void singDuckSong (
public class Lyrics
public static void mainString args
singDuckSong;
private static void singDuckSong
for int i ; i ; i
singVersei;
printQuacksi;
singFinalVerse;
printQuacks;
private static void singVerseint numDucks
printDucksHeadingnumDucks;
printOverTheHillAndFarAway;
printMotherDuckSays;
printDucksReturnednumDucks;
private static void singFinalVerse
System.out.printlnSad mother duck went out one day,";
printOverTheHillAndFarAway;
printMotherDuckSays;
System.out.printlnAnd all of the five little ducks came back.";
System.out.println; Empty line
private static void printDucksHeadingint numDucks
String numberWord convertToWordsnumDucks;
String ducksWord numDucks "duck" : "ducks";
System.out.printlnnumberWord little ducksWord went out one day,";
private static void printOverTheHillAndFarAway
System.out.printlnover the hill and far away.";
private static void printMotherDuckSays
System.out.printlnMother duck said, Quack quack, quack, quack.;
private static void printDucksReturnedint numDucks
if numDucks
System.out.printlnBut none of the five little ducks came back.";
else
System.out.printlnBut only convertToWordsnumDucks toLowerCase little ducks came back.";
private static void printQuacksint numDucks
System.out.printlnQuack quack, quack, quack, quack, quack.";
private static String convertToWordsint number
switch number
case :
return "Five";
case :
return "Four";
case :
return "Three";
case :
return "Two";
case :
return "One";
default:
return "none";
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started