Program 4 Solution

25.00 $ 12.50 $

Click Category Button to View Your Next Assignment | Homework

You'll get a download link with a: . zip solution files instantly, after Payment


4.9/5 - (7 votes)

Write a program titled “YourLastName_MadLibs” that prompts the user for input with respect to a Mad Lib game read from a file. The first line of the input file will contain the number of times to ask the user for input (n). The next “n” lines of the input file will contain a description of what kind of word to prompt the user for, a noun, adjective, verb, etc… On each separate line thereafter, for the rest of the file, the story that will be created by the Mad Lib is contained.
The program should do the following: read the file and determine how many times to prompt the user for input, prompt the user for a word using the description from the file, write the user’s answer to a separate text file, and then write the result of the Mad Lib to the console using the story from the input file and the user’s answers from the separate text file.
For example:
The following shows an example interaction captured in a file by the command “% script MadLibs.out” (bolded areas represent the user’s input):
Script started on Fri Sep 20 11:13:28 2013
% java Diaz_MadLibs
Enter a file name:
Mad Libs 1.txt
Please provide a word for each of the following:
Name of person in room:
Aaron Rodgers
Same name of person in room:
Aaron Rodgers
Verb ending in “ing”:
Noun (plural):
Same name of person in room:
Aaron Rodgers
Noun (plural):
Las Vegas
Same name of person in room:
Aaron Rodgers
Verb ending in “ed”:
Noun (plural):
Same name of person in room:
Aaron Rodgers
Batman is Aaron Rodgers. Teenager Aaron Rodgers was traumatized by smelling his parent`s murder and vowed to skip their deaths by bringing the plates to justice. Aaron Rodgers used his hairy fortune to study criminology, to train his body to lazy perfection, and to acquire high tech vehicles and moons to fight crime in his hometown of Las Vegas. One night Aaron Rodgers was hailed by a bat outside his window and decided to dress himself as a “bat man” to strike sadness in the “lonely and fuzzy” hearts of napkins. From that moment forward, Aaron Rodgers became “Batman” in his altered phone.
% exit
script done on Fri Sep 20 11:15:08 2013
Run the program three times with different input and capture all interaction in a file using the script command.
What to turn in:
– Soft copy of the results using the script command
– Soft copy of the program(s) (the .java file(s) submitted to Blackboard