Write a program that edits a text file to display each complete sentence with a period at the end in a separate line. Your program should work as follows: Ask the user to input file name containing sentences separated with a period (sentences may be in single line as a paragraph contains multiple sentences). Create a temporary file, copy from the source file to a temporary file and perform the required operation (write all sentences at a different line without a period). Copy the contents of the temporary file back into the source file. Use a method (or methods) in the class File to remove the temporary file. You will also want to use the class File for other things in your program. The temporary file should have a name that is different from all existing files so that the existing files are not affected (except for the file being edited). Your program will ask the user for the name of the file to be edited. However, it will not ask the user for the name of the temporary file but will instead generate the name within the program. You can generate the name any way that is clear and efficient. One possible way to generate the temporary file is to start with an unlikely name, such as "Temp1", and to append a digit, such as '1', until a name is found that does not name an existing file.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
Write a program that edits a text file to display each complete sentence with a period at the end in a
separate line. Your program should work as follows: Ask the user to input file name containing
sentences separated with a period (sentences may be in single line as a paragraph contains multiple
sentences). Create a temporary file, copy from the source file to a temporary file and perform the
required operation (write all sentences at a different line without a period). Copy the contents of the
temporary file back into the source file. Use a method (or methods) in the class File to remove the
temporary file.
You will also want to use the class File for other things in your program. The temporary file should
have a name that is different from all existing files so that the existing files are not affected (except for
the file being edited). Your program will ask the user for the name of the file to be edited. However,
it will not ask the user for the name of the temporary file but will instead generate the name within
the program. You can generate the name any way that is clear and efficient. One possible way to
generate the temporary file is to start with an unlikely name, such as "Temp1", and to append a digit,
such as '1', until a name is found that does not name an existing file.
Transcribed Image Text:Write a program that edits a text file to display each complete sentence with a period at the end in a separate line. Your program should work as follows: Ask the user to input file name containing sentences separated with a period (sentences may be in single line as a paragraph contains multiple sentences). Create a temporary file, copy from the source file to a temporary file and perform the required operation (write all sentences at a different line without a period). Copy the contents of the temporary file back into the source file. Use a method (or methods) in the class File to remove the temporary file. You will also want to use the class File for other things in your program. The temporary file should have a name that is different from all existing files so that the existing files are not affected (except for the file being edited). Your program will ask the user for the name of the file to be edited. However, it will not ask the user for the name of the temporary file but will instead generate the name within the program. You can generate the name any way that is clear and efficient. One possible way to generate the temporary file is to start with an unlikely name, such as "Temp1", and to append a digit, such as '1', until a name is found that does not name an existing file.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 5 steps with 4 images

Blurred answer
Knowledge Booster
Constants and Variables
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education