Question
JAVA , write simple program , work up to chapter 6 only Data files : Raven Mad Lib.txt The Farm Mad Lib.txt The purpose of
JAVA , write simple program , work up to chapter 6 only
Data files : Raven Mad Lib.txt The Farm Mad Lib.txt
The purpose of this file is to create a program that will read a Mad Lib file, allow the user to check for points to place the new words. Then output the result to a new text file. Words in the original file that need to be replaced begin and end with (). For example, the first line of Raven Mad Lib.txt looks like:
Once upon a (timeofday) dreary, while I (word), weak and weary,
Anytime your program finds a word that start with a parenthesis '(' it should then ask the user to replace that word with whatever is inside the "()"
A sample Execution of the code would look like the following:
Please type in the name of the file : The Farm Mad Lib.txt Please type in the name of the output flle : Output.txt While reading your file I found (adjective), please type in the replacement : fuzzy While reading your file I found (noun), please type in the replacement : fox .... While reading your file I found (verb), please type in the replacement : kick Your file is done. The output should be in Output.txt
Then in that file should be the replacement file.
Notes
For the file names, you will want to do nextLine() in case they use spaces.
All replacement words start and end with parenthesis. () so you know what to look for.
So you will nee to both read and write from a file at the same time.
Most of the time you will just read a word and then turn around and write it to a file.
You don't need to worry about newline characters, your output can just be a single long line.
You should not however have a single word per line.
If you want to get fancy, you could put a newline character every 10th word.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
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