Question: Provide a class for authoring a simple letter. In the constructor, supply the names of the sender and the recipient: Construct an object of the

Provide a class for authoring a simple letter. In the constructor, supply the names of the sender and the recipient:

public Letter (String from, String to) Supply a method public void addLine(String

line) to add a line of text to the body of the

Construct an object of the Letter class and call addLine twice.
(1) Use the concat method to form a longer string from two shorter strings.

(2) The special string "" represents a new line. For example, the statement body = body.concat("Sincerely,").concat("");
adds a line containing the string "Sincerely," to the body.

public Letter (String from, String to) Supply a method public void addLine(String line) to add a line of text to the body of the letter. Supply a method public String getText() that returns the entire text of the letter. The text has the form: Dear recipient name: blank line first line of the body second line of the body last line of the body blank line Sincerely, blank line sender name

Step by Step Solution

3.50 Rating (157 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Lets create a class called Letter that will allow us to author a simple letter with a sender and rec... View full answer

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 Java Programming Questions!