Initials.java.html

  1  import java.util.Scanner;
  2  
  3  /**
  4     This program prints a pair of initials.
  5  */
  6  public class Initials
  7  {
  8     public static void main(String[] args)
  9     {
 10        Scanner in = new Scanner(System.in);
 11  
 12        // Get the names of the couple
 13  
 14        System.out.print("Enter your first name: ");
 15        String first = in.next();
 16        System.out.print("Enter your significant other's first name: ");
 17        String second = in.next();
 18  
 19        // Compute and display the inscription
 20  
 21        String initials = first.substring(0, 1) 
 22           + "&" + second.substring(0, 1);
 23        System.out.println(initials);
 24     }
 25  }