// Solution to Assignment 2 import java.io.*; public class Assignment2 { // Declare three private variables to store first name, last name // and university private String firstName; private String lastName; private String university; // method to get the inputted values from keyboard public void getName() throws IOException { BufferedReader br = new BufferedReader (new InputStreamReader(System.in)); System.out.println("Please enter your first name: "); firstName = br.readLine(); System.out.println("Please enter your last name: "); lastName = br.readLine(); System.out.println("Please enter the name of the University to which you want to aaply"); university = br.readLine(); } // method to print the letrer public void printLetter() { System.out.println(); // print first two lines of the letter // by using only one "System.out.println" for several lines System.out.println("To: Admissions Office, Graduate School, \n" + " " + university + "\n"); // print the first paragraph // by using one "System.out.println" for each line. System.out.println("I, " + firstName + " " + lastName + ","); System.out.println("have just received a Bachelor degree in Computer Science"); System.out.println("from the University of Texas at El Paso. I am very much interested in"); System.out.println("studying further, and I would therefore like to apply for"); System.out.println("your graduate program.\n"); // print the last three lines of the letter System.out.println("Please find all the required documents attached.\n\n" + "Youres \n\n" + firstName); } public static void main(String[] args) throws IOException { // Call two methods Assignment2 a = new Assignment2(); // Call two methods a.getName(); a.printLetter(); } }