COSC 2010 / 2100 Data Structures

Fall 2018

Homework Assignment #1 : MailMerge

Due: Wednesday, September 5th, 11:59pm CDT
Submit: Turn in your MailMerge.java source file using the turnin command on morbius.mscs.mu.edu.
Work is to be completed individually. Be certain to include your name in the file. You may submit multiple times, but only the last turnin will be kept. The automatic submission system will not accept work after the deadline. (See turnin instructional video HERE.)

The Eclipse Integrated Development Environment and Java are already installed on the laboratory machines. If you would like to use another computer to do your work, it is your responsibility to ensure that the necessary software is installed. You may employ any Java development environment with which you are comfortable.

Include a comment block at the very top of each file that looks as follows:

/**
 * COSC 2100 - Project 1
 * Explain briefly the functionality of the class.
 * @author [your name]
 * Instructor [your instructor]
 * TA-BOT:MAILTO [your email address]
 */

MailMerge

Write a mail merge application called MailMerge.java. Your program should read the input for the problem from System.in. The expected input will consist of three parts:

Once all of the input has been read, the program should output should be a series of exact copies of the form letter template, with the occurrences of tag specifications replaced by corresponding items from the database.

Example Runs

In the examples below, I use text in blue to distinguish the output of the program from the input I typed. This is for purpose of clarity only; your program will not print text in different colors.

Example Run #1

<<N>> <<A>> <<G>>
John 35 male
Sally 28 female
Megan 55 female
---
Dear <<N>>,

Because you are <<A>> years old and <<G>>, we have a free gift for you. You have absolutely nothing to buy; just pay the shipping and handling charge of $9.99.
To claim your gift, call us immediately.
Thank you,

Office of Claims Department

The output from this input should be:

Dear John,

Because you are 35 years old and male, we have a free gift for you. You have absolutely nothing to buy; just pay the shipping and handling charge of $9.99.
To claim your gift, call us immediately.
Thank you,

Office of Claims Department
---
Dear Sally,

Because you are 28 years old and female, we have a free gift for you. You have absolutely nothing to buy; just pay the shipping and handling charge of $9.99.
To claim your gift, call us immediately.
Thank you,

Office of Claims Department
---
Dear Megan,

Because you are 55 years old and female, we have a free gift for you. You have absolutely nothing to buy; just pay the shipping and handling charge of $9.99.
To claim your gift, call us immediately.
Thank you,

Office of Claims Department
---

Note how the tags <<N>>, <<A>>, and <<G>> were treated as placeholders for the person's name, age, and gender.

Example Run #2

<<L>>
Brylow
Chamberlain
Homayounpour
Osterberg
---
Hi, <<L>>!

The output from this input should be:

Hi, Brylow!
---
Hi, Chamberlain!
---
Hi, Homayounpour!
---
Hi, Osterberg!
---

Notes

Points for this assignment will be awarded primarily based upon successful completion of a battery of testcases.

The instructor's implementation of this project makes use of the built-in Java library classes java.util.ArrayList, java.util.Scanner, and java.util.regex.Pattern, as well as the String class. You might also like to use these, but there are many, many approaches to solving this problem.


[back]

[Revised 2018 Aug 29 23:03 DWB]