Question Description

Write a Java program to generate text for an email.

1. Prompts for a contact name, an item to order, and a number of items to order. These 3 items can all be strings.

2. Using the input data from above and the 3 string values given below, replace the corresponding data with the inputted data.

A. Replace $CONTACT$ with the contact name.

B. Replace $COUNT$ with the number of items ordered.

C. Replace $ITEMS$ with the item to order.

D. Use the String value returned from the method below “shipDOW()” to replace “$DOW$”.

E. Use the String value returned from the method below “referenceNumber()” to replace “$REF$”.

3. Build a new String named emailMsg and combine the results of the 3 strings. This needs to be in the order given. Do not use + symbol. Instead use the concat() method.

An example of the result is :

Dear Professor Keith,Your order for 4 Java Books will be shipped Thursday.The reference number is 1554160008584

Using these 3 String variables.

String salutation = “Dear $CONTACT$,n”; String customerInfo = “Your order for $COUNT$ $ITEMS will be shipped $DOW$. n”;
String orderNumber = “The reference number is $REF$n”;

Include these methods:

// The shipDOW method will require these imports

import java.util.Calendar;

import java.util.Locale;

public static String shipDOW() {

Calendar in3days = Calendar.getInstance();
in3days.add(Calendar.DAY_OF_YEAR, 3);
return in3days.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.LONG_FORMAT, Locale.getDefault());

public static String referenceNumber() {
return Long.toString(System.currentTimeMillis());