Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Mad Libs is a phrasal template word game which consists of one player prompting others for a list of words to substitute for blanks
Mad Libs is a phrasal template word game which consists of one player prompting others for a list of words to substitute for blanks in a story before reading aloud. The game is frequently played as a party game or as a pastime. The madlib phrase you will use as a template is: The the . where: adjective: words that describe the qualities or states of being of nouns subject: non-primary nouns (person, place, thing) that is the subject of the sentence Past-tense verb: an action that took place previously Object: non-primary nouns (person, place, thing) that is the object of the sentence So, for example, a sample run of this program could produce (with random words in ): The the . Write a program that will prompt the user to either create their own madlib or randomly generate and display a madlib. Begin by creating a program called Madlibs.java, that does the following: 1. Declare and initialize 4 arrays to match each of the word types described above (adjective, subject, verb, object) a. Each array should contain at least 15 examples of that type of word. b. For example: String[] adjectives - ("silly", "quick", "blue",...); 2. Declare an instance of the Random class in order to generate random numbers a. Ex: Random ran new Random(); b. Don't forget to import java.util.Random; 3. Continuously prompt the user to indicate whether they want to create a new madlib or have one randomly generated. a. You should continue to generate mad libs following the template above until the user indicates that the program should quit. b. You can decide how to get this input (i.e. what data type to use), but must validate the input regardless. c. Be sure to use print statements to let the graders know what input the program is expecting. 4. If the user indicates that they want to randomly generate a mad lib, you should use the Random object (described in #2 above) in order to generate 6 random numbers. a. Each number corresponds to a word type- and indicates which word will be returned from the String arrays described in #1. 1. The numbers generated need to be in the range of the length of each corresponding word array. These numbers will represent the index values of the random words that you will select from each array. ii. iii. iv. You should save all 6 integers in another array (int[] indices) You will not receive full credit if you use Math.random () to generate these random values b. Using the array holding the index values, you can generate and display a mad lib for the user. i. For example, if indices = 114,3,4,4,0,1), then the words in the mad lib would be pulled from the arrays in the following order: The the . c. Be sure that there are no duplicates of adjectives in your final mad lib d. You do not need to include the '
Step by Step Solution
★★★★★
3.50 Rating (160 Votes )
There are 3 Steps involved in it
Step: 1
Heres a possible solution to the Mad Libs problem import javautilRandom import javautilScanner publi...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