MailMerge.java
source file
using the turnin command on morbius.mscs.mu.edu.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]
*/
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:
<<A>>
, with an alphabet
letter between two sets of angle brackets. ---
".---
" should be considered the
contents of a form letter with tags to be replaced.
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.
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.
<<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.
<<L>>
Brylow
Chamberlain
Homayounpour
Osterberg
---
Hi, <<L>>!
The output from this input should be:
Hi, Brylow!
---
Hi, Chamberlain!
---
Hi, Homayounpour!
---
Hi, Osterberg!
---
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.
[Revised 2018 Aug 29 23:03 DWB]