java programming

posted by .

Provide a class called Letter for authoring a simple letter. The letter class has three data fields, the name of the sender, the name of the recipient, a body of the letter.
1. Supply the class constructors (default , and overloaded )
2. Supply a method.
Public void addLine (String Line)

To add a line of text to the body of the letter
The addLine method should through an exception if the line is empty.
3. 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
Blank line
Sender name
4. Also supply a program LetterPrinter that asks the user to enter lines of text nd verifies that the lines are not empty and prints the following letter :
Dear teacher:
Line supplied by the user
Line supplied by the user

Student name

  • java programming -

    This is the code what i tried but its not thw thing i want

    import javax.swing.*;
    public class Letter

    private String sendername;
    private String recipientname;
    private String bodyletter;

    public static void sender (String nsender)
    String name= "a";


    public static void recipient (String nrecipient)
    String name= "b";

    public static void letter (String bletter)
    String letter="Studentletter";

    public static void addLine (String line)
    String linea=" ";

    public String getText()
    String body= "Dear natasha";
    String line2 =" ";
    String line3=" Student of java class";
    // System.out.println(line3);
    String line4="question";
    // System.out.println(line4);
    String line5="sincerely";
    String line6=" ";
    String line7="john";
    // System.out.println(line7);
    String n =body+ "\n "+ line2 + "\n" + line3 + "\n" + line4 + "\n" + line5 + "\n" + line6 + "\n" + line7;
    //return n ;
    return getText();
    public static void letterPrinter()
    String s1="Dear Teacher !";
    String user="I am a student of class java.";
    String s= s1 + "\n" + user;

    String ns ="Sincerely ,";
    String line6=" ";

    String student = "b";
    String a =ns +"\n" + student;

    public static void main(String[] args)




  • java programming -

    Here are some java programming tutorials that I hope will help you and don't forget the Related Questions down below:


  • java programming -

    What does happen?

Respond to this Question

First Name
School Subject
Your Answer

Similar Questions

  1. history

    need these letters unscrambled to make a nine letter word relating to native americans R E T A M I L A F The 4 letter is E the 5th letter is R and the 6th letter is I
  2. French

    Our French class was given an assignment where each student would write a letter in French to a child in the 5th grade. I have looked up letter writing in French but I can only find ways to write formal letters. How would I begin the …
  3. English

    1. According to 'spacing words', write the following right. Iaminmyfirstyear. -> I am in my first year. 2. Let's write down the self-introductory passage on the memo on the left. 3. Correct the following self-introductory passage …
  4. human resources

    at school i was asked to write a job letter. this letter will be send to a bank in order for that person to get a loan. whats the correct name of the letter?
  5. Grammar

    What exsits or orcurrs in space that is 19 spaces long. The sencond letter is a P. The 9 letter is a R, the 12th letter n and the last letter is n. Thank you.
  6. English 8R - Business Letter Assignment Help!

    I have this assignment for my English class. We have to write a business letter to a someone, it can be famous or not. The best part is that we can actually send it to them. So I choose Obama. It's a two paragraph letter. The 1st paragraph, …
  7. programming

    a) Define a Cat class. A Cat has name. Define two constructors, one with no argument and another with the name as its argument. Initialize the name to a default value Unknown for the zero-argument constructor. b) Create a main class. …
  8. critical probability

    in how many ways can be the first four letters of your name be arranged to form a three letter word, (i)when the letter can be repeated (ii)when the letter can not be repeated
  9. english

    Solve this riddle :- my first letter is in chocolate but not in gram. My second letter is in cake and also in jam. My third letter in time table is easily found. My whole name is a friend who's often around. What am I?
  10. Programming

    Widget company runs a small factory that makes several types of nuts and bolts. They employ (a)1 (b)2 (c)3. Each factory worker can work a maximum of (a)40 hours normal working hours per week. All hours over 40 are paid as over-time …

More Similar Questions