I need help with the following questions in Java please. Create a class named Fo
ID: 3557271 • Letter: I
Question
I need help with the following questions in Java please.
Create a class named FormLetterWriter that includes two overloaded methods named displaySalutation(). The first method takes one String parameter that represents a customer's last name, and it displays the salutation "Dear Mr. or Ms." followed by the last name. The second method accepts two String parameters that represent a first and last name, and it displays the greeting "Dear" followed by the first name, a space, and the last name. After each salutation, display the rest of a short business letter: "Thank you for your recent order." Write a main() method that tests each overloaded method.
Explanation / Answer
public class FormLetterWriter {
public void displaySalution(String lName){
System.out.println("Dear Mr. " + lName);
System.out.println("Thank You for your recent order");
}
public void displaySalution(String fName, String lName){
System.out.println("Dear " + fName + " " + lName);
System.out.println("Thank You for your recent order");
}
public static void main(String args[]){
String fName = "David";
String lName = "Beckham";
FormLetterWriter letterWriter = new FormLetterWriter();
letterWriter.displaySalution(lName);
letterWriter.displaySalution(fName, lName);
}
}