Question: Write a program in java that will perform a mail merge. Background When companies need to send out the same letter to many different customers,

Write a program in java 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

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>In the letter, the codes <title>, <name>, <balance>, and <days> indicate the place-holders which need to be filled in with customer data.</p> <p>Your starter code also includes a file named <strong>collectionNames1.txt</strong>. The contents of this file is as follows:</p> <p>Mr.,Smith,102.50,10 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: <title> = "Mr." <name> = "Smith: <balance> = 102.50 <days> = 10</p> <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>The algorithm that you can use to create this program is as follows:</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 "<title>" with the customer's title.</p> <p>Using the <strong>replace</strong> method from the String class, replace "<name>" with the customer's name.</p> <p>Using the <strong>replace</strong> method from the String class, replace "<balance>" with the customer's balance.</p> <p>Using the <strong>replace</strong> method from the String class, replace "<days>" with the customer's days overdue.</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>Remember that at this stage, COMMENTING IS A REQUIREMENT! Make sure you FULLY comment your program. You must include comments that explain what sections of code is doing. Notice the key word "sections"! This means that you need not comment every line in your program. Write comments that describe a few lines of code rather than "over-commenting" your program.</p> <p>You MUST write comments about every method that you create. Your comments must describe the purpose of the method, the purpose of every parameter the method needs, and the purpose of the return value (if the method has one).</p> <p>Build incrementally. Don't tackle the entire program at once. Write a little section of the program, then test it AND get it working BEFORE you go any further. Once you know that this section works, then you can add a little more to your program. Stop and test the new code. Once you get it working, then add a little bit more. </p> <p>Make sure you FULLY test your program! Make sure to run your program multiple times, inputting combinations of values that will test all possible conditions for your IF statements and loops. Also be sure to test border-line cases.</p> </div> <div class="question-answer-divider"></div> <section class="answerHolder" itemscope itemtype="http://schema.org/Answer"> <div class="answerHolderHeader"> <h2>Step by Step Solution</h2> <div class="answerReviews"> <div class="starIcon"> </div> </div> </div> <div class="questionProperties"> <p>There are 3 Steps involved in it</p> <div class="cart-flex"> <div class="cart cart1"> 1 Expert Approved Answer </div> </div> </div> <div class="step org_answer"> <span class="view_solution_btn view-solution-btn-cursor"> <strong class="step-heading step-1">Step: 1 <span>Unlock <i class="fa-solid fa-lock"></i></span></strong> </span> <img src="https://www.solutioninn.com/includes/images/document_product_info/blur-text-image.webp" class="blured-ans-image" width="759" height="271" alt="blur-text-image" decoding="async" fetchpriority="high"> <div class="step1Popup"> <span class="heading">Question Has Been Solved by an Expert!</span> <p>Get step-by-step solutions from verified subject matter experts</p> <button class="view_solution_btn step1PopupButton">View Solution</button> </div> </div> <div class="step"> <span class="view_solution_btn view-solution-btn-cursor"> <strong class="accordion step-heading">Step: 2 <span>Unlock <i class="fa-solid fa-lock"></i></span></strong> </span> </div> <div class="step"> <span class="view_solution_btn view-solution-btn-cursor"> <strong class="accordion step-heading">Step: 3 <span>Unlock <i class="fa-solid fa-lock"></i></span></strong> </span> </div> </section> <section class="relatedQuestion"> <h3>Students Have Also Explored These Related Databases Questions!</h3> <div class="relatedQuestionSliderHolder"> <div class="relatedQuestionCart "> <p class="heading">Q: </p> <a class="relatedQuestionText" href="/study-help/questions/write-a-project-that-will-perform-a-mail-merge-starter-13619612" > Write a project that will perform a mail merge. STARTER CODE project parta getting started 1. Click the Open IDE button. 2. In the IDE window, look in the leftmost column and find the CSCI 1010... </a> </div> <div class="relatedQuestionCart "> <p class="heading">Q: </p> <a class="relatedQuestionText" href="/study-help/questions/write-a-program-that-will-perform-a-mail-merge-program-13529063" > 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... </a> </div> <div class="relatedQuestionCart "> <p class="heading">Q: </p> <a class="relatedQuestionText" href="/study-help/questions/write-a-program-that-will-perform-a-mail-merge-background-12447090" > 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... </a> </div> <div class="relatedQuestionCart "> <p class="heading">Q: </p> <a class="relatedQuestionText" href="/study-help/questions/topic-conducting-personal-job-interviews-using-the-star-model-1design-3536657" > Topic: Conducting personal job interviews using the star model 1-Design a two-hour training work plan for 10 trainees 2-Determine the quality of trainees 3-Use the training design model Formulate one... </a> </div> <div class="relatedQuestionCart "> <p class="heading">Q: </p> <a class="relatedQuestionText" href="/study-help/questions/i-hope-you-can-answer-this-question-and-find-the-5404022" > I hope you can answer this question and find the reference below the question. Thank you Topic: Conducting personal job interviews using the STAR model 1- Design a two-hour training work plan for 10... </a> </div> <div class="relatedQuestionCart "> <p class="heading">Q: </p> <a class="relatedQuestionText" href="/study-help/questions/certificate-iv-in-finance-and-mortgage-broking-fn540820-page-26325891" > CERTIFICATE IV IN FINANCE AND MORTGAGE BROKING - FN540820 Page 1 UNIT 9 MANAGE PERSONAL AND PROFESSIONAL DEVELOPMENT Unit Code: BSBPEF501 This unit describes the skills and knowledge required to... </a> </div> <div class="relatedQuestionCart "> <p class="heading">Q: </p> <a class="relatedQuestionText" href="/study-help/questions/please-post-two-email-usage-guidelines-that-you-feel-are-24242911" > Please post two email usage guidelines that you feel are most important to follow and tell us why you feel those guidelines are important (guidelines may be found online or from your experience). 1.... </a> </div> <div class="relatedQuestionCart "> <p class="heading">Q: </p> <a class="relatedQuestionText" href="/study-help/questions/i-have-to-create-a-program-in-c-and-i-13645013" > I have to create a program in C and I can't figure it out. The program has to read a source file. Please help. /******************************************************************** PROJECT: Glossary... </a> </div> <div class="relatedQuestionCart "> <p class="heading">Q: </p> <a class="relatedQuestionText" href="/study-help/questions/there-are-two-problems-due-this-week-each-worth-35-2988316" > There are two problems due this week (each worth 35 points) as follows. Case 5-1David L. Miller: Portrait of a White-Collar Criminal (page 144). In comprehensive paragraphs, answerrequirements 1?6.... </a> </div> <div class="relatedQuestionCart "> <p class="heading">Q: </p> <a class="relatedQuestionText" href="/study-help/questions/page-1-of-20-print-publication-date-jul-2017-subject-2934389" > Page 1 of 20 Print Publication Date: Jul 2017 Subject: Law, IT and Communications Law Online Publication Date: Dec 2016 DOI: 10.1093/oxfordhb/9780199680832.013.45 Gregory N. Mandel The Oxford... </a> </div> <div class="relatedQuestionCart "> <p class="heading">Q: </p> <a class="relatedQuestionText" href="/a-063-kg-ball-thrown-directly-upward-with-an-initial" > A 0.63 kg ball thrown directly upward with an initial speed of 14 m/s reaches a maximum height of 8.1 m. What is the change in the mechanical energy of the ball-Earth system during the ascent of the... </a> </div> <div class="relatedQuestionCart "> <p class="heading">Q: </p> <a class="relatedQuestionText" href="/consider-the-p-pi-and-modified-i-control-systems-discussed" > Consider the P, PI, and modified I control systems discussed in Examples 10.6.2, 10.6.3, and 10.6.4. The plant transfer function is 1/(Is + c), where I = 10 and c = 3. Investigate the performance of... </a> </div> <div class="relatedQuestionCart "> <p class="heading">Q: </p> <a class="relatedQuestionText" href="/study-help/questions/in-reviewing-the-financial-reports-the-practice-manager-notices-that-27896076" > In reviewing the financial reports, the practice manager notices that Green Valley s average days in accounts receivable ( AR ) have increased from 4 0 to 6 5 days over the past year. What does this... </a> </div> <div class="relatedQuestionCart "> <p class="heading">Q: </p> <a class="relatedQuestionText" href="/study-help/questions/ct-corp-comprehensive-question-canadian-tire-corporation-limited-canadian-15961854" > CT Corp Comprehensive Question Canadian Tire Corporation, Limited ( Canadian Tire ) is a family of companies that includes a retail segment and a financial services division, among others. The retail... </a> </div> <div class="relatedQuestionCart "> <p class="heading">Q: </p> <a class="relatedQuestionText" href="/study-help/business-communication-essentials/a-recent-trend-in-the-funeral-home-industry-is-for-2117786" > A recent trend in the funeral home industry is for mortuaries to have websites from which friends and family members of the deceased can send e-mail or electronic greeting cards. The URL for the... </a> </div> <div class="relatedQuestionCart "> <p class="heading">Q: </p> <a class="relatedQuestionText" href="/study-help/business-communication-essentials/teamwork-brians-food-service-is-expanding-its-catering-division-it-2117788" > Teamwork. Brians Food Service is expanding its catering division. It needs an additional enclosed truck with a refrigeration unit; several propane ovens to keep food warm; and storage shelves and... </a> </div> <div class="relatedQuestionCart "> <p class="heading">Q: </p> <a class="relatedQuestionText" href="/study-help/business-communication-essentials/technology-you-have-searched-the-web-and-found-several-vendors-2117787" > Technology. You have searched the Web and found several vendors who offer business promotional merchandise at unit prices your new business can afford. Each of the websites speaks of quantity... </a> </div> </div> <nav class="navigationButtons"> <a class="previousQuestionButton" href="/study-help/questions/complete-using-matlab-please-disply-code-and-output-command-window-12651514">Previous Question</a> <a class="nextQuestionButton" href="/study-help/questions/which-of-the-following-is-trueselect-onea-a-list-12651516">Next Question</a> </nav> </section> </main> <aside class="expertRight"> <section class="relatedBook" style="margin-bottom:40px; width: 100%;" > <div class="bookHolder" > <div class="relatedBookHeading" > <h2 class="heading">Recommended Textbook</h2> </div> <div class="bookMainInfo" > <div class="bookImage" style="width: 100px !important; min-width: 100px; flex-shrink: 0; margin-right: 20px;"> <a href="/textbooks/microsoft-office-365-for-beginners-2022-8-in-1-1st-edition-979-8833565759-198454"> <img src="https://dsd5zvtm8ll6.cloudfront.net/si.question.images/book_images/2024/01/65a23711ceb93_74565a23711c995d.jpg" width="100" height="131" alt="Microsoft Office 365 For Beginners 2022 8 In 1" loading="lazy" style="width: 100px !important;"> </a> <a href="/textbooks/computer-science-adobe-indesign-2475" style="margin-top: 8px; display: block; text-align: left;">More Books</a> </div> <div class="bookInfo" style="text-align: left;"> <span class="bookTitle" style="text-align: left;"> <a href="/textbooks/microsoft-office-365-for-beginners-2022-8-in-1-1st-edition-979-8833565759-198454" style="text-align: left;"> Microsoft Office 365 For Beginners 2022 8 In 1 </a> </span> <div class="bookMetaInfo" style="text-align: left;"> <p class="bookAuthor" style="text-align: left;"> <b>Authors:</b> <span>James Holler</span> </p> <p class="bookEdition" style="text-align: left;"> 1st Edition </p> <p class="bookEdition" style="text-align: left;"> B0B2WRC1RX, 979-8833565759 </p> </div></div></div> </div> </section> <div class="post-question-section"> <div class="description-question-section"> <span class="post-question-section-title">Ask a Question and Get Instant Help!</span> </div> <div class="text-area-post-question"> <form action="/study-help/post-question?ref=search" method="post" enctype="multipart/form-data"> <textarea rows="4" class="form-control form-posting-margin" name="textarea-question-content" id="textarea-question-content" placeholder="Type Your Question ...."></textarea> <button type="submit" class="btn btn-sm btn-submit-post-question text-center">Get Answer</button> </form> </div> </div> </aside> </div> </div> <div class="promo items-center justify-center hidden"> <div class="app_promo"> <span class="app_promo_dismiss"> <i class="fa-solid fa-x"></i> </span> <div class="app-button"> <div class="image-wrapper"> <img width="30" height="30" src="https://www.solutioninn.com/includes/images/rewamp/common/mobile-app-logo.png" decoding="async" fetchpriority="high" alt="SolutionInn App Logo"> <strong>Study Help</strong> </div> <button class="app_promo_action redirection" data-question-open-url='q_id=12651515&q_type=2'> Open in App </button> </div> </div> </div> </div> </div> <div class="blank-portion"></div> <footer> <div class="container footerHolder"> <div class="footerLinksFlex"> <div class="footerLinksCol col-md-3 col-lg-3 col-sm-6 col-6"> <p>Services</p> <ul> <li><a href="/site-map">Sitemap</a></li> <li><a href="/fun/">Fun</a></li> <li><a href="/study-help/definitions">Definitions</a></li> <li><a href="/tutors/become-a-tutor">Become Tutor</a></li> <li><a href="/books/used-textbooks">Used Textbooks</a></li> <li><a href="/study-help/categories">Study Help Categories</a></li> <li><a href="/study-help/latest-questions">Recent Questions</a></li> <li><a href="/study-help/questions-and-answers">Expert Questions</a></li> <li><a href="/clothing">Campus Wear</a></li> <li><a href="/sell-books">Sell Your Books</a></li> </ul> </div> <div class="footerLinksCol col-md-3 col-lg-3 col-sm-6 col-6"> <p>Company Info</p> <ul> <li><a href="/security">Security</a></li> <li><a href="/copyrights">Copyrights</a></li> <li><a href="/privacy">Privacy Policy</a></li> <li><a href="/conditions">Terms & Conditions</a></li> <li><a href="/solutioninn-fee">SolutionInn Fee</a></li> <li><a href="/scholarships">Scholarship</a></li> <li><a href="/online-quiz">Online Quiz</a></li> <li><a href="/study-feedback">Give Feedback, Get Rewards</a></li> </ul> </div> <div class="footerLinksCol col-md-3 col-lg-3 col-sm-6 col-6"> <p>Get In Touch</p> <ul> <li><a href="/about-us">About Us</a></li> <li><a href="/support">Contact Us</a></li> <li><a href="/career">Career</a></li> <li><a href="/jobs">Jobs</a></li> <li><a href="/support">FAQ</a></li> <li><a href="https://www.studentbeans.com/en-us/us/beansid-connect/hosted/solutioninn" target="_blank" rel="noopener nofollow">Student Discount</a></li> <li><a href="/campus-ambassador-program">Campus Ambassador</a></li> </ul> </div> <div class="footerLinksCol col-md-3 col-lg-3 col-sm-6 col-12"> <p>Secure Payment</p> <div class="footerAppDownloadRow"> <div class="downloadLinkHolder"> <img src="https://dsd5zvtm8ll6.cloudfront.net/includes/images/rewamp/common/footer/secure_payment_method.png" class="img-fluid mb-3" width="243" height="28" alt="payment-verified-icon" loading="lazy"> </div> </div> <p>Download Our App</p> <div class="footerAppDownloadRow"> <div class="downloadLinkHolder mobileAppDownload col-md-6 col-lg-6 col-sm-6 col-6 redirection" data-id="1"> <img style="cursor:pointer;" src="https://dsd5zvtm8ll6.cloudfront.net/includes/images/rewamp/home_page/google-play-svg.svg" alt="SolutionInn - Study Help App for Android" width="116" height="40" class="img-fluid mb-3 " loading="lazy"> </div> <div class="downloadLinkHolder mobileAppDownload col-md-6 col-lg-6 col-sm-6 col-6 redirection" data-id="2"> <img style="cursor:pointer;" src="https://dsd5zvtm8ll6.cloudfront.net/includes/images/rewamp/home_page/apple-store-download-icon.svg" alt="SolutionInn - Study Help App for iOS" width="116" height="40" class="img-fluid mb-3" loading="lazy"> </div> </div> </div> </div> </div> <div class="footer-bottom"> <p>© 2026 SolutionInn. All Rights Reserved</p> </div></footer> <script> window.addEventListener("load",function(){jQuery(document).ready(function(t){ // Clarity tracking (function(c,l,a,r,i,t,y){ c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)}; t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i; y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y); })(window, document, "clarity", "script", "sjv6tuxsok"); // Helper to read a cookie by name function getCookie(name) { return document.cookie .split('; ') .map(v => v.split('=')) .reduce((acc, [k, val]) => (k === name ? decodeURIComponent(val || '') : acc), ''); } // Read cookies var si = getCookie('si_u_id'); var uid = getCookie('u_id'); var zen = getCookie('zenid'); // Send to Clarity if (si) clarity('set', 'si_u_id', si); if (uid) clarity('set', 'u_id', uid); if (zen) clarity('set', 'zenid', zen); clarity('set', 'ip_address', '216.73.216.134'); t.ajax({type:"POST",url:"/",data:{trackUserActivity:!0,reqUri:document.URL,referer:document.referrer},success:function(t){}})})},!1),window.addEventListener("load",function(){jQuery(document).ready(function(t){t.ajax({type:"POST",url:"/",data:{insertCrawler:!0,reqUri:document.URL,parseTime:"0.056",queryTime:"0.01654768548584",queryCount:"30"},success:function(t){}})})},!1),window.addEventListener("load",function(){jQuery(document).ready(function(){function t(t="",n=!1){var i="itms-apps://itunes.apple.com/app/id6462455425",e="openApp://action?"+t;isAndroid()?(setTimeout(function(){return window.location="market://details?id=com.solutioninn.studyhelp",!1},25),window.location=e):isIOS()?(setTimeout(function(){return window.location=i,!1},25),window.location=e):(i="https://apps.apple.com/in/app/id6462455425",n&&(i="https://play.google.com/store/apps/details?id=com.solutioninn.studyhelp"),window.open("about:blank","_blank").location.href=i)}jQuery("#appModal").modal("show"),jQuery(".download-app-btn").click(function(){t(jQuery(this).attr("data-question-open-url"))}),jQuery(".redirection").click(function(){var n=jQuery(this).attr("data-question-open-url"),i=jQuery(this).attr("data-id");void 0!=n?1==i?t(n,!0):t(n,!1):1==i?t("",!0):t("",!1)}),jQuery(".app-notification-close").click(function(){jQuery(".app-notification-section").css("visibility","hidden");var t=new FormData;t.append("hide_notification",!0),jQuery.ajax({type:"POST",url:"/",data:t,cache:!1,contentType:!1,processData:!1,beforeSend:function(){},success:function(t){location.reload()}})})})},!1); </script> </body> </html>