Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Challenge: Document Merger Description: Merge text documents provided by the user into a new file. Purpose: This application provides experience with user input and interaction

Challenge: Document Merger

Description: Merge text documents provided by the user into a new file.

Purpose: This application provides experience with user input and interaction in the Console, writing files to disk, reading files from disk, working with exceptions, and writing programs in C#/.NET.

Requirements:

Project Name: Document Merger Target Platform: Console Programming Language: C#

Documentation:

  • Types and variables (Links to an external site.) (Microsoft)
  • Console.ReadLine Method () (Links to an external site.) (Microsoft)
  • Strings (C# Programming Guide) (Links to an external site.) (Microsoft)
  • How to read from and write to a text file by using Visual C# (Links to an external site.) (Microsoft)
  • StreamWriter Class (Links to an external site.) (Microsoft)
  • Exceptions and Exception Handling (C# Programming Guide) (Links to an external site.) (Microsoft)

This program is to display the name of the app Document Merger followed by a blank line, prompt the user for the names of two documents (which should be in the current directory) and save a new document in the current directory, and display a message if it was successful or unsuccessful based on a specification provided. The filename of the document is the names of the provided files merged together. Verify that the filenames the user enters exist at the point they enter the name. If the file doesnt exist, give the user feedback that the file doesnt exist and prompt them for another filename.

When the program runs:

  1. Display Document Merger followed by a blank line.
  2. Prompt the user for the name of the first text file.
  3. Verify that the first file exists. If not, give the user feedback and let them re-enter the first filename.
  4. Prompt the user for the name of the second document.
  5. Verify that the second file exists. If not, give the user feedback and let them re-enter the second filename.
  6. Merge the two file names and append .txt to the end (this includes removing the existing .txt extensions from the names).
  7. Read and merge the text of the two files.
  8. Save the content to a file in the current directory.
  9. If an exception occurs, output the exception message and exit.
  10. If an exception does not occur, output [filename] was successfully saved. The document contains [count] characters. and exit. [filename] and [count] are placeholders for the filename of the document and the number of characters it contains.
  11. After the program does or does not fail to merge the files, ask the user if they would like to merge two more files. If they do, prompt them again for input. If not, exit the program.

Note that the requirements say the files should all be in the current directory. This means you can use just the file name as the path for the file. If you do that, the file will be saved/read in the current directory for the application. When I created the project and called it Document Merger, a directory called Document Merger was created that contains Document Merger.sln and another directory called Document Merger. The Document Merger directory inside of the project is the current directory when the application runs and is where you will find the files that are saved.

Close open streams in the finally block of a try-catch-finally. Caution: test a variable holding a reference to a stream to make sure it is not null before calling the Close method on it. Calling a method on a null reference will crash the application.

PLEASE MAKE THIS AS SIMPLE AS POSSIBLE. THANKS.

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

Database Marketing The Ultimate Marketing Tool

Authors: Edward L. Nash

1st Edition

0070460639, 978-0070460638

More Books

Students also viewed these Databases questions

Question

Can a diode be used to amplify a signal? Explain.

Answered: 1 week ago

Question

How can you use sentence style to emphasize key thoughts? [LO-5]

Answered: 1 week ago

Question

Project management skills and/or experience desirable

Answered: 1 week ago