im new to java help me wit this question (you might think what the hell am i doin)
question is:
Using a series of methods, output the popular song "My Bonnie Lies Over the Ocean". However, instead of using "Bonnie", allow the users to enter a name of their choice.
Lyrics:

My Bonnie lies over the ocean 
My Bonnie lies over the sea 
My Bonnie lies over the ocean 
Oh bring back my Bonnie to me 
Bring back, bring back 
Bring back my Bonnie to me, to me 
Bring back, bring back 
Bring back my Bonnie to me 
Last night as I lay on my pillow 
Last night as I lay on my bed 
Last night as I lay on my pillow 
I dreamed that my Bonnie was dead 
Bring back, bring back 
Bring back my Bonnie to me, to me 
Bring back, bring back 
Bring back my Bonnie to me 
Oh blow ye the winds o'er the ocean 
And blow ye the winds o'er the sea 
Oh blow ye the winds o'er the ocean 
And bring back my Bonnie to me 
Bring back, bring back 
Bring back my Bonnie to me, to me 
Bring back, bring back 
Bring back my Bonnie to me 
The winds have blown over the ocean 
The winds have blown over the sea 
The winds have blown over the ocean 
And brought back my Bonnie to me 
Bring back, bring back 
Bring back my Bonnie to me, to me 
Bring back, bring back 
Bring back my Bonnie to me 

This is what ive done so far:

// The "Lyrics" class.
public class Lyrics
{
    public static void main (String[] args)
    {
       System.out.println ("My Bonnie lies over the ocean");

     } // end of main method

public static double 

} // end of Lyrics class

i really dont know what to do wit it plz guys help me

Edited 3 Years Ago by mike_2000_17: Fixed formatting

You don't need this: public static double

At your system.out, instead of Bonnie, you will have a variable. And according to your assignment the user will give this value from the keyboard.

And from what I see the song has many lines that repeat so you can store these lines to variables and print them instead of having to write them all over again.

i have to use series of method to do this question so can u jus help me wit to do like a verse im new to this so i don really understand, if u jus tell me to do somethin...

Use English, not "text-speak", and first make your own attempt at your homework. Please read the rules and FAQ for the terms of the forum.

I'm sorry for using "text speak". And not put my effort in it...
anyway here is my work can you guys just check it out and help me with it?
import java.util.Scanner;

/** A class which hold the Lyric in an array of String */
public class Lyrics
{
String[] song = {
"My Bonnie lies over the ocean",
"My Bonnie lies over the sea",
"My Bonnie lies over the ocean",
"Oh bring back my Bonnie to me",
"Bring back, bring back",
"Bring back my Bonnie to me, to me",
"Bring back, bring back"
};


// method that returns the song
String[] getSong() {
return song;
}


// static method to do the job
public static void main (String[] args)
{
// pickup by what replacing "Bonnie"
String name;
Scanner scan = new Scanner(System.in);
System.out.print ("Enter the name of the user: ");
name = scan.next();
// Get an instance of Lyrics
Lyrics lyrics = new Lyrics();
// Get the song lines
String[] str = lyrics.getSong();
// lopp thru all lines
for(int i = 0; i < str.length; i++) {
// replacing "Bonnie" by the name I have scanned
System.out.println(str.replaceAll("Bonnie", name));
}
} // end of main method
} // end of Lyrics class
<br />import java.util.Scanner;<br /><br />/** A class which hold the Lyric in an array of String */<br />public class Lyrics<br />{<br />    String[] song = {<br />          "My Bonnie lies over the ocean", <br />          "My Bonnie lies over the sea", <br />            "My Bonnie lies over the ocean", <br />          "Oh bring back my Bonnie to me", <br />          "Bring back, bring back", <br />         "Bring back my Bonnie to me, to me", <br />          "Bring back, bring back"<br />       };<br /><br />    // method that returns the song<br />    String[] getSong() {<br />       return song;<br />   }<br /><br /> // static method to do the job<br /> public static void main (String[] args)<br />    {<br />      // pickup by what replacing "Bonnie"<br />       String name;<br />       Scanner scan = new Scanner(System.in);<br />     System.out.print ("Enter the name of the user: ");<br />     name = scan.next();<br />        // Get an instance of Lyrics<br />       Lyrics lyrics = new Lyrics();<br />      // Get the song lines<br />      String[] str = lyrics.getSong();<br />       // lopp thru all lines<br />     for(int i = 0; i < str.length; i++) {<br />           // replacing "Bonnie" by the name I have scanned<br />           System.out.println(str.replaceAll("Bonnie", name));<br />        }<br />  } // end of main method<br />} // end of Lyrics class<br />

Edited 3 Years Ago by happygeek: fixed formatting

Does it execute, and does it print what you want? And what are these things at the end of your post:

<br />import java.util.Scanner;<br /><br />/** A class which hold the Lyric in an array of String */<br />public class Lyrics<br />{<br /> String[] song = {<br /> "My Bonnie lies over the ocean", <br /> "My Bonnie lies over the sea", <br /> "My Bonnie lies over the ocean", <br /> "Oh bring back my Bonnie to me", <br /> "Bring back, bring back", <br /> "Bring back my Bonnie to me, to me", <br /> "Bring back, bring back"<br /> };<br /><br /> // method that returns the song<br /> String[] getSong() {<br /> return song;<br /> }<br /><br /> // static method to do the job<br /> public static void main (String[] args)<br /> {<br /> // pickup by what replacing "Bonnie"<br /> String name;<br /> Scanner scan = new Scanner(System.in);<br /> System.out.print ("Enter the name of the user: ");<br /> name = scan.next();<br /> // Get an instance of Lyrics<br /> Lyrics lyrics = new Lyrics();<br /> // Get the song lines<br /> String[] str = lyrics.getSong();<br /> // lopp thru all lines<br /> for(int i = 0; i < str.length; i++) {<br /> // replacing "Bonnie" by the name I have scanned<br /> System.out.println(str.replaceAll("Bonnie", name));<br /> }<br /> } // end of main method<br />} // end of Lyrics class<br />

This article has been dead for over six months. Start a new discussion instead.