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

Question 1(One-dimensional array) You are hired to invent a Mad Libs like game;

ID: 3936036 • Letter: Q

Question

Question 1(One-dimensional array) You are hired to invent a Mad Libs like game; but this version is for some amusing POEM WRITING. You are implementing a simple prototype to write a POEM that is inspired by wilderness and the nature theme. Your program will ask the user to enter a set of relevant nouns and adjectives that will be used to generate different versions of a poem. You can assume each poem has 3 lines. Your program should proceed as follows:

1. Display a welcome message and ask the user to enter a set of nouns and adjectives. Store the nouns in one array and the adjectives in another array for further processing. The user should enter 3 nouns and 3 adjectives at least.

2. Generate your poem by choosing at random combinations of noun and adjectives.

3. You are not allowed to pick a noun or an adjective again until you have used all sets of noun and adjectives that the user has provided, respectively.

4. Your poem should be displayed in the format below (regardless how the user enters the nouns/adjectives)

5. The user can proceed by choosing different versions of the poem

6. When the user chooses to stop, your program should display a closing message like: ‘ Thank you for using our JAVA POEM GENERATOR’

Explanation / Answer

Since no formatis mentioned I have did it randomly


package poemgenerator;

import static java.lang.System.exit;
import java.util.Random;
import java.util.Scanner;

public class PoemGenerator {
private String noun[] = new String[10];
private String adj[] = new String[10];
Scanner sc = new Scanner(System.in);
Random ran = new Random();
public void readWords(){
System.out.print("Enter at least three nouns:");
int i,j=3;
for(i=0;i<j;i++){
noun[i] = sc.next();
//if(i<3)
// j = 10;
}
System.out.print("Enter at least three adjectives:");
j = 3;
for(i=0;i<j;i++){
adj[i] = sc.next();
//if(i<3)
// j = 10;
}
  
}
public void generatePoem(){
String choice;
int index1=0,index2=0,i;
do{
System.out.println("1.Wilderness[w] 2.Nature theme[n] 3.stop[stop] Select your option: ");
choice = sc.next();
switch(choice){
case "w":this.readWords();
for(i=ran.nextInt(noun.length);i<noun.length;i++){
for(int j=ran.nextInt(adj.length);j<adj.length;j++)
index1 = ran.nextInt(noun.length);
index2 = ran.nextInt(adj.length);
System.out.println(noun[index1] +" "+adj[index2]);
}
break;
case "n":this.readWords();
for(i=ran.nextInt(noun.length);i<noun.length;i++){
for(int j=ran.nextInt(adj.length);j<adj.length;j++)
index1 = ran.nextInt(noun.length);
index2 = ran.nextInt(adj.length);
System.out.println(noun[index1] +" "+adj[index2]);
}
break;
case "stop":System.out.println(" 'Thank you for using our JAVA POEM GENERATOR’");
exit(0);
break;
default: System.out.println("Choose correct option:");
}
}while(choice != "stop");
}
public static void main(String[] args) {
PoemGenerator p = new PoemGenerator();
p.generatePoem();
}
  
}

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