Question: Provide a class for authoring a simple letter. In theconstructor, supply the names of the sender and therecipient: public Letter(String from, String to) Supply a

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

   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 theform:

    Dear recipientname:

   blankline

  firstline of the body

   second line of thebody

   .....

   last line of thebody

   blankline

   sincerely,

   blankline

   sendername

Also supply a program LetterPrinter that prints thisletter.

   Dear John:

   I am sorry we must part.

   I wish you all the best

   Sincerely,

   Mary

Construct an object of the letter class and call addLinetwice.

Step by Step Solution

3.52 Rating (159 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To fulfill this task we need to create a Letter class in Java that allows for authoring a simple letter by specifying the sender and recipient adding ... 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 Programming Questions!