Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This assignment focuses on file input/output and strings. Turn in files named MadLibs.java and mymadlib.txt. Mad Libs are short stories that have blanks called placeholders

image text in transcribedimage text in transcribedimage text in transcribed

This assignment focuses on file input/output and strings. Turn in files named MadLibs.java and mymadlib.txt. "Mad Libs" are short stories that have blanks called placeholders to be filled in. In the non-computerized version of this game, one person asks a second person to fill in each of the placeholders without the second person knowing the overall story. Once all placeholders are filled in, the second person is shown the resulting story, often with humorous results In this assignment you present a menu to the user with three options: create a new mad lib, view a previously created mad lib, or quit. These are shown as C, V, and Q, case-insensitively. If any other command is typed, the user is re-prompted. When creating a new mad lib, the program prompts the user for input and output file names. Then the program reads the input file, prompting the user to fill in any placeholders that are found without showing the user the rest of the story. As the user fills in each placeholder, the program writes the resulting text to the output file. The user can later view the mad lib that was created or quit the program. The log below shows one sample execution of the program Welcome to the game of Mad Libs I will ask you to provide various words and phrases to fillin a storv The result will be written to an output file Console Interaction (C) reate mad-lib, (V)iew mad-lib, (Q)uit? c Input file name: oops.txt File not found. Try again TORZON. txt File not found. Try again:tarzan. ExE Output file name: out1.txt Please type an adiective: sill Lease type a plural noun: apples Please type a noun: frisbee Please type an adiective: hun Please type a place: Tacoma Lease type a plural noun: , bees Please type a noun: umbrella Please type a funny noise bu Please type an adjective: shin Please type a noun jelly donu Please type an adjective: beautiful PLease type a plural noun: Spoons Please t Your mad-lib has been created a, person's name? Keanu Reeves (C) reate mad-lib, (V)iew mad-lib, (Q)uit? X (C) reate mad-lib, (V)iew mad-lib, (Q) uit? I don't understand (C) reate mad-lib, (V) iew mad-lib, (Q)uit? Input file name OUT001.txt File not found. Try again: i forget the file name File not found. Try again: SOmethin File not found. Try again: Ou One of the most silly characters in fiction is named "Tarzan of the apples ." Tarzan was raised by a/an Irisbee and Jives in the hungry jungle in the heart of darkest Tacoma , WA He spends most of his time eating bees and swinging from tree to umbrella . Whenever he gets angry, he beats on his chest and says, " burp"This is his war cry. Tarzan always dresses in shiny shorts made from the skin of a/an jelly donut and his best friend is a/an beautiful chimpanzee named Cheetah. He is supposed to be able to speak to elephants and spoons . In the movies, Tarzan is played by Keanu Reeves (C) reate mad-lib, (V) iew mad-lib, () uit? Notice that if an input file is not found, either for creating a mad-lib or viewing an existing one, the user is re-prompted. No re-prompting occurs for the output file. If the output file does not already exist, it is created. If it does already exist, its contents are overwritten. (These are the default behaviors in Java.) You may assume that the output file is not the same file as the input file 1 of 3 This assignment focuses on file input/output and strings. Turn in files named MadLibs.java and mymadlib.txt. "Mad Libs" are short stories that have blanks called placeholders to be filled in. In the non-computerized version of this game, one person asks a second person to fill in each of the placeholders without the second person knowing the overall story. Once all placeholders are filled in, the second person is shown the resulting story, often with humorous results In this assignment you present a menu to the user with three options: create a new mad lib, view a previously created mad lib, or quit. These are shown as C, V, and Q, case-insensitively. If any other command is typed, the user is re-prompted. When creating a new mad lib, the program prompts the user for input and output file names. Then the program reads the input file, prompting the user to fill in any placeholders that are found without showing the user the rest of the story. As the user fills in each placeholder, the program writes the resulting text to the output file. The user can later view the mad lib that was created or quit the program. The log below shows one sample execution of the program Welcome to the game of Mad Libs I will ask you to provide various words and phrases to fillin a storv The result will be written to an output file Console Interaction (C) reate mad-lib, (V)iew mad-lib, (Q)uit? c Input file name: oops.txt File not found. Try again TORZON. txt File not found. Try again:tarzan. ExE Output file name: out1.txt Please type an adiective: sill Lease type a plural noun: apples Please type a noun: frisbee Please type an adiective: hun Please type a place: Tacoma Lease type a plural noun: , bees Please type a noun: umbrella Please type a funny noise bu Please type an adjective: shin Please type a noun jelly donu Please type an adjective: beautiful PLease type a plural noun: Spoons Please t Your mad-lib has been created a, person's name? Keanu Reeves (C) reate mad-lib, (V)iew mad-lib, (Q)uit? X (C) reate mad-lib, (V)iew mad-lib, (Q) uit? I don't understand (C) reate mad-lib, (V) iew mad-lib, (Q)uit? Input file name OUT001.txt File not found. Try again: i forget the file name File not found. Try again: SOmethin File not found. Try again: Ou One of the most silly characters in fiction is named "Tarzan of the apples ." Tarzan was raised by a/an Irisbee and Jives in the hungry jungle in the heart of darkest Tacoma , WA He spends most of his time eating bees and swinging from tree to umbrella . Whenever he gets angry, he beats on his chest and says, " burp"This is his war cry. Tarzan always dresses in shiny shorts made from the skin of a/an jelly donut and his best friend is a/an beautiful chimpanzee named Cheetah. He is supposed to be able to speak to elephants and spoons . In the movies, Tarzan is played by Keanu Reeves (C) reate mad-lib, (V) iew mad-lib, () uit? Notice that if an input file is not found, either for creating a mad-lib or viewing an existing one, the user is re-prompted. No re-prompting occurs for the output file. If the output file does not already exist, it is created. If it does already exist, its contents are overwritten. (These are the default behaviors in Java.) You may assume that the output file is not the same file as the input file 1 of 3

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Database Foundations Technology Fundamentals For IT Success

Authors: Bob Bryla

1st Edition

0782143725, 9780782143720

More Books

Students also viewed these Databases questions