Question: Write a program that will perform a mail merge. Program Description: When your program starts, it will be given the name of letter file and

Write a program that will perform a mail merge.

Program Description:

When your program starts, it will be given the name of letter file and the name of a data file. Your program should read the letter file, and for each place-holder-code found in the letter file, you should replace the place-holders with data found in the data file. Your program should create one output file for each line of data in the data file (in other words, if there are 3 lines of data in the data file, then your program should create 3 output files).

Your program must store the all of the integers in an array. The maximum number of integers that you can expect is 100, however there may not necessarily be that many. Your program should allow the user to continue entering numbers until they enter a negative number or until the array is filled - whichever occurs first. If the user enters 100 numbers, you should output an message stating that the maximum size for the list has been reached, then proceed with the calculations.

Your starter code includes a file named collection1.txt. The contents of this file is as follows:

Dear

<name>, Please remember that the balance on your account (<balance>) remains unpaid. It was due to be paid in full <days> days ago. Enclosed is an envelope in which you may mail your payment. If, by chance, you have already sent your payment, please disregard this letter and accept our gratitude. Thank you <p> --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------</p> <p>In the letter, the codes </p><title>, <name>, <balance>, and <days> indicate the place-holders which need to be filled in with customer data. <p>Your starter code also includes a file named <strong>collectionNames1.txt</strong>. The contents of this file is as follows:</p> <p> --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------</p> <p>Mr.,Smith,102.50,10</p> <p>Mrs.,James,59.76,14 Ms.,Abrams,147.70,12 Mr.,Sessoms,112.10,18</p> <p>In the data file, each line of text represents one customer. The customer data on one line is separated by commas. Thus the first line of data from the data file is: Mr.,Smith,102.50,10 and this represents the following data: </p><title> = "Mr." <name> = "Smith: <balance> = 102.50 <days> = 10 <p>You should use these files to test your program, and you are also encouraged to create your own TXT files to test with.</p> <p>Output Files</p> <p>For the example "collectionNames1.txt", there are four lines of data, so your program is expected to create four output files. The names of the ouput files should match the names of the customers. So for this example, you would create a file named <strong>Smith.txt</strong>, a file named <strong>James.txt</strong>, a file named <strong>Abrams.txt</strong> and a file named <strong>Sessoms.txt</strong>.</p> <p>The contents of each of these files should be a copy of the input file, but with the correct data in the place holders. So the Smith.txt file should look like this:</p> <p>Dear Mr. Smith, Please remember that the balance on your account (102.50) remains unpaid. It was due to be paid in full 10 days ago. Enclosed is an envelope in which you may mail your payment. If, by chance, you have already sent your payment, please disregard this letter and accept our gratitude. Thank you </p> <p>and the James.txt file should look like this:</p> <p>Dear Mrs. James, Please remember that the balance on your account (59.76) remains unpaid. It was due to be paid in full 14 days ago. Enclosed is an envelope in which you may mail your payment. If, by chance, you have already sent your payment, please disregard this letter and accept our gratitude. Thank you </p> <p> </p> <p><strong>The algorithm that you can use to create this program is as follows:</strong></p> <p>Create an array of Strings to hold the lines of text from the letter file. This is a partially-filled array, as you will not know how many lines of text will need to be stored.</p> <p>Open the letter file. Read all of the lines of text from this file and store each line into a different position in the letter array.</p> <p>Close the letter file as you will no longer need it.</p> <p>Open the data file.</p> <p>For each line of text found in the data file:</p> <p>Read the line and store it into a simple String variable.</p> <p>Use the <strong>split</strong> method from the String class to split the line of text into four separate strings (the four pieces of data which are separated by commas). The result of this method will produce a String array where each position in the array will contain one of the pieces of data (i.e. pos 0 will contain the title, pos 1 will contain the name, pos 2 will contain the balance and pos 3 will contain the days).</p> <p>Open an output file where the name of the file should be the customer's name, followed by ".txt". So if the customer's name is "Smith" then the filename should be "Smith.txt".</p> <p>For each String found in the letter array (the first array):</p> <p>Make a copy of the string (so you don't mess up the original)</p> <p>Using the <strong>replace</strong> method from the String class, replace "</p><title>" with the customer's title. <p>Using the <strong>replace</strong> method from the String class, replace "<name>" with the customer's name.<ame></ame></name></p> <p>Using the <strong>replace</strong> method from the String class, replace "<balance>" with the customer's balance.</balance></p> <p>Using the <strong>replace</strong> method from the String class, replace "<days>" with the customer's days overdue.</days></p> <p>Write the changed line into the output file</p> <p>Close the output file</p> <p> </p> <p>Technical notes, restrictions, and hints:</p> <p>There is no keyboard input and no screen output for this program. All input data comes from the input files, and all output should be written to files.</p> <p>You may assume that the form letter will not contain more than 15 lines. Therefore, the partially-filled array that you will create to hold the form letter should be created to be size 15.</p> <p>There is a MAXLETTERSIZE constant which is already set to 15. Use it to create the letter array.</p> <p>DO NOT attempt to read the entire data file and store the whole thing into an array. This file could actually contain more lines of data than you have RAM memory to hold --- so it may not even be possible to create an array large enough to hold the entire file. You should read and process one line of data at a time.</p> <p>The starter code contains lines which already correctly get the filenames. The filenames are passed into your program from the command line, and will be found in the "<strong>args</strong>" array which is a parameter to the main method. args[0] will contain the letter file name and args[1] will contain the data file name.</p> <p>There is the beginning of a <strong>generateLetter</strong> method in the starter code. You should use this method to create the letter for ONE customer. Thus, you will call this method one time for each line of data found in the data file. The parameters for this method are as follows:</p> <p>letter = the array containing the lines of text from the template letter</p> <p>letterSize = the used size of the letter array (remember, it's partially filled)</p> <p>data = an array containing the four pieces of customer data (title, name, balance, days)</p> <p>Absolutely NO other global variables (class variables) are allowed (except for the keyboard object).</p> <p>NO BREAK STATEMENTS TO EXIT LOOPS</p> <p><img style="height:724px;width:612px;" src="https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f45f1f540d2_16666f45f1ec8f5b.jpg" alt="Write a program that will perform a mail merge. Program Description: When"></p> <p><img style="height:733px;width:577px;" src="https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f45f201afb8_16766f45f1f97f4a.jpg" alt="your program starts, it will be given the name of letter file"></p> <p><img style="height:798px;width:569px;" src="https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f45f20c6fd5_16866f45f20474af.jpg" alt="and the name of a data file. Your program should read the"></p> <p><img style="height:662px;width:576px;" src="https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f45f21bc7c9_16966f45f213933f.jpg" alt="letter file, and for each place-holder-code found in the letter file, you"></p> <p><img style="height:752px;width:568px;" src="https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f45f227c770_16966f45f21ef799.jpg" alt="should replace the place-holders with data found in the data file. Your"></p> <p><img style="height:574px;width:832px;" src="https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f45f231f566_17066f45f22b2c2e.jpg" alt="program should create one output file for each line of data in"></p> <p><img style="height:290px;width:773px;" src="https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f45f23c3f9b_17166f45f235f432.jpg" alt="the data file (in other words, if there are 3 lines of"></p> <p><img style="height:503px;width:672px;" src="https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f45f2474017_17166f45f23f2f00.jpg" alt="data in the data file, then your program should create 3 output"></p> project part a getting started 1. Click the Open IDE button 2. In the IDE window, look in the leftmost column and find the CSCI 1010 folder and inside it, find the project11 folder 3. Open the Java file - MailMerge.java the project Write a program that will perform a mail merge Background When companies need to send out the same letter to many different customers, they usually have a form letter which contains "place-holder codes". Then, they will also create a list of data that will be used to fill in the place-holders in the form letter. A mail merge program is designed to create one copy of the template letter for each person's name that appears in the list. Program Description When your program starts, it will be given the name of letter file and the name of a data file. Your program should read the letter file, and for each place-holder-code found in the letter file, you should replace the place-holders with data found in the data file. Your program should create one output file for each line of data in the data file (in other words, if there are 3 lines of data in the data file, then your program should create 3 output files). Your program must store the all of the integers in an array. The maximum number of integers that you can expect is 100, however there may not necessarily be that many. Your program should allow the user to continue entering numbers until they enter a negative number or until the array is filled whichever occurs first. If the user enters 100 numbers, you should output an message stating that the maximum size for the list has been reached, then proceed with the calculations. Input Files The names of the input files are given to your program from the command line, when you type the command to execute your program. So, for example, you can test your program with the example files given by typing: MailMerge collection1.txt collectionNames1.txt

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!