In: Computer Science
using java:
There's a hole in the bottom of the sea There's a hole in the bottom of the sea There's a hole, there's a hole There's a hole in the bottom of the sea There's a log in the hole in the bottom of the sea There's a log in the hole in the bottom of the sea There's a hole, there's a hole There's a hole in the bottom of the sea There's a bump on the log in the hole in the bottom of the sea There's a bump on the log in the hole in the bottom of the sea There's a hole, there's a hole There's a hole in the bottom of the sea Want at least 5 inputs from the user (variables), meaning you'll also end up printing 5 different verses or stanza.
Dear student,
The code in JAVA programming language to the above problem statement given by you is as follows :
CODE :
import java.io.*;
import java.util.*;
public class Main
{
public static void main(String[] args)
{
Scanner in=new Scanner(System.in);
String words[]= new String[5];
System.out.println("Please enter a word");
words[0]=in.nextLine()+" in the";//takes the first word from the
user
for(int i=1;i<5;i++)//rest of the words
{
System.out.println("Please enter a word");
words[i]=in.nextLine()+" in the "+words[i-1];//takes the word from
the user
}
for(int i=0;i<5;i++)//to print the verses
{
String ins1="There's a "+words[i]+" hole in the bottom of the
sea";
System.out.println(ins1);
System.out.println(ins1);
System.out.println("There's a hole, there's a hole");
System.out.println("There's a hole in the bottom of the
sea");
System.out.println();
}
}
}
SAMPLE OUTPUT :
I have tried to explain it in very simple language and I hope that i have answered your question satisfactorily.Leave doubts in comment section if any.