Write a program that prompts the user to enter a file name, then opens the file in text mode and reads it line by line.
Write a program that prompts the user to enter a file name, then opens the file in text mode and reads it line by line. While entering the file name, the program should allow the user to type quit to exit the program. If the file with a given name does not exist, then display a message and allow the user to re-enter the file name.
The file can contain one or more sentences. The program should accept as input each sentence in which all the words are run together, but the first character of each word is uppercase. Convert sentences to strings in which the words are separated by spaces and only the first word starts with an uppercase letter. For example, the string StopAndSmellTheRoses. would be converted to Stop and smell the roses. Sentences are separated by periods ('.'), exclamation marks ('!'), or question marks ('?'). Ensure that there is one space character in between sentences.(I NEED JAVA CODE).
OUTPUT SHOULD BE LIKE THIS
standard input
text1.txt
Required Output
Please enter the file name or type QUIT to exit: Stop and smell the roses.
standard input
txt1.txt text1.txt
Required Output
Please enter the file name or type QUIT to exit: File 'txt1.txt' is not found. Please re-enter the file name or type QUIT to exit: Stop and smell the roses.
Standard Input
text2.txt
Please enter the file name or type QUIT to exit: A true rebel you are! Everyone was impressed. You'll do well to continue in the same spirit. Please explain a bit more in the way of footnotes. From the given text it's not clear what are we reading about.
standard input
somefile.txt anotherbadfile.txt quit
Required Output
Please enter the file name or type QUIT to exit: File 'somefile.txt' is not found. Please re-enter the file name or type QUIT to exit: File 'anotherbadfile.txt' is not found. Please re-enter the file name or type QUIT to exit:
Step by Step Solution
There are 3 Steps involved in it
Step: 1
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