Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Current Trends In Database Technology Edbt 2006 Edbt 2006 Workshops Phd Datax Iidb Iiha Icsnw Qlqp Pim Parma And Reactivity On The Web Munich Germany March 2006 Revised Selected Papers Lncs 4254

Authors: Torsten Grust ,Hagen Hopfner ,Arantza Illarramendi ,Stefan Jablonski ,Marco Mesiti ,Sascha Muller ,Paula-Lavinia Patranjan ,Kai-Uwe Sattler ,Myra Spiliopoulou ,Jef Wijsen

2006th Edition

3540467882, 978-3540467885

More Books

Students also viewed these Databases questions

Question

2. What process will you put in place to address conflicts?

Answered: 1 week ago