Mad Libs is a phrasal template word game which consists of one player prompting others for...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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 <adjective> <adjective> <subject> <verb> the <adjective> <object>. 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 <quick> <black> <dog> <passed> the <lazy> <cat>. ● 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 <adjective [indices [0]]> <adjective [indices [1]]> <subject [indices [2]]> <verb [indices [3]]> the <adjective [indices [4]]> <object [indices [5]]>. c. Be sure that there are no duplicates of adjectives in your final mad lib d. You do not need to include the '<' and characters in your output. 5. If the user indicates that they want to create a mad lib, you should prompt them to enter each word as it appears in the template sentence. Concatenate the words together (with spaces), and display the mad lib back to the user. Sample output (for guidance): Do you want to create your own madlib? (Y or anything else to quit): n Your random madlib: The soft quick bird jumped the chill dog Do you want to create your own madlib? (Y or Nanything else to quit): a Your random madlib: The slow soft student smelled the hardworking library Do you want to create your own madlib? (Y or anything else to quit): y Please enter an adjectiver silly Enter another adjective: cute Enter a subject: turtle Enter a past tense verb: wan Enter another adjectives fast Enter an objects home Tour madlib: The silly cute turtle suas the fast hose Do you want to create your own madlib? (Y or K is not a valid wenu option. Goodbye anything else to quit): k 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 <adjective> <adjective> <subject> <verb> the <adjective> <object>. 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 <quick> <black> <dog> <passed> the <lazy> <cat>. ● 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 <adjective [indices [0]]> <adjective [indices [1]]> <subject [indices [2]]> <verb [indices [3]]> the <adjective [indices [4]]> <object [indices [5]]>. c. Be sure that there are no duplicates of adjectives in your final mad lib d. You do not need to include the '<' and characters in your output. 5. If the user indicates that they want to create a mad lib, you should prompt them to enter each word as it appears in the template sentence. Concatenate the words together (with spaces), and display the mad lib back to the user. Sample output (for guidance): Do you want to create your own madlib? (Y or anything else to quit): n Your random madlib: The soft quick bird jumped the chill dog Do you want to create your own madlib? (Y or Nanything else to quit): a Your random madlib: The slow soft student smelled the hardworking library Do you want to create your own madlib? (Y or anything else to quit): y Please enter an adjectiver silly Enter another adjective: cute Enter a subject: turtle Enter a past tense verb: wan Enter another adjectives fast Enter an objects home Tour madlib: The silly cute turtle suas the fast hose Do you want to create your own madlib? (Y or K is not a valid wenu option. Goodbye anything else to quit): k
Expert Answer:
Answer rating: 100% (QA)
Heres a possible solution to the Mad Libs problem import javautilRandom import javautilScanner publi... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
Create a class named myString , which consists of one string data member and three functions Input the string from the user at run time then call the following functions on it void Count Consonants()...
-
Mad Libs is a childrens game in which they provide a few words that are then incorporated into a silly story. The game helps children understand different parts of speech because they are asked to...
-
Mad Libs is a childrens game in which the players provide a few words that are then incorporated into a silly story. For example, you might ask a child for the name of an animal, a number, and a...
-
Write a program that displays the color study shown at right, which gives Albers squares corresponding to each of the 256 levels of blue (blue-to-white in row major order) and gray (black-to-white in...
-
You wish to project the image of a slide on a screen 9.00 m from the lens of a slide projector. (a) If the slide is placed 15.0 cm from the lens, what focal length lens is required? (b) If the...
-
An article in Obesity Research [Impaired Pressure Natriuresis in Obese Youths (2003, Vol. 11, pp. 745751)] described a study in which all meals were provided for 14 lean boys for three days followed...
-
Consider the following information: Assuming the forward rate was used to forecast the future spot rate, determine whether the Canadian dollar or the Japanese yen was forecasted with more accuracy,...
-
A taxpayer is about to receive a $ 1,000 bonus payment from his employer. He would like to put this bonus into a retirement account. He has come to you for advice as to whether he should put the $...
-
Trans-Pacific Lumber runs a mill in the Northwest that produces two grades of lumber, A and B, and a by-product, sawdust. The company chooses to allocate the costs on the basis of the physical...
-
What's the rate of return you would earn if you paid $1,500 for a perpetuity that pays $100.65 per year?
-
1)What is the relationship between clients' age (number) and their confidence in quitting smoking (scale)? a)Determine which statistical test is most appropriate. Explain your rational. b)What are...
-
Sketch both of these graphs by using the Following data: Graph #1 f(2)= undefined f(-3) = 3 lim f(x) = 1 x-27 lim f(x) = 5 Graph #2 lim f(x) = 1 x -00 lim f(x) = -4 x+00 lim_ f(x) = 3 x-4 lim f(x) =...
-
Four months after the merger between two auto insurance companies, Green Lizard and Global Promise, Priya Shama was hired to oversee the merger of the claims department for both companies. The newly...
-
Explain the purpose and state on which financial statement the following belong and provide a short example of each: Research and Development, Accumulated Amortization, Amortization Expense.
-
Find the general solution of the following differential equation. Primes denote derivatives with respect to x. 1 (xy' + y) (8+x) = 6x The general solution is y(x) = .
-
Consider the phenomenon of workplace politics. What are some contributing factors and how might an organizational manager reduce the impact of workplace politics?
-
QUESTION 21 QUESTION 22 QUESTION 23 QUESTION 24: QUESTION 25:. 12-21. (Calculating project cash flows and NPV) Garcia's Truckin', Inc. is considering the purchase of a new production machine for...
-
What is the maximum volume of 0.25 M sodium hypochlorite solution (NaOCl, laundry bleach) that can be prepared by dilution of 1.00 L of 0.80 M NaOCl?
-
Suppose the only good you ever consume is Nestle's Crunch bars. What is your income elasticity of demand for Nestle's Crunch bars? What is your price elasticity of demand for Nestle's Crunch bars?
-
Contrast the effects on employment, output, and wages of (a) a year of bad weather resulting in low agricultural productivity and (b) nuclear contamination that lowers agricultural productivity...
-
Suppose the government imposes a temporary sales tax-one that is in effect for a short time, but will disappear in the future. In a diagram relating current consumption to future consumption, how...
-
Many groups have treasury policies that use hedging of net positions. They would look at their group-wide exposure in, e.g. foreign currency and then take forward contracts to cover the position....
-
On 1 April year 1, a deep discount bond was issued by DDB AG. It had a face value of 2.5 million covering a five-year term.The lenders were granted a discount of 5%. The coupon rate was 10% on the...
-
Interest rate swaps can be designated as hedges of underlying borrowings. A swap of floating for fixed rate is a cash flow hedge, but a swap of fixed for floating is a fair value hedge. Why?
Study smarter with the SolutionInn App