/*
 * SquareRoot.java     Authors: Koffman and Wolz
 * Demonstrates square root method (Math.sqrt())
 */

import javax.swing.JOptionPane;

public class SquareRoot {
   public static void main (String[] args) {
      // Get two numbers.
      String n1Str = 
            JOptionPane.showInputDialog("Enter first number");
      int n1 = Integer.parseInt(n1Str);

      String n2Str =
            JOptionPane.showInputDialog("Enter second number");
      int n2 = Integer.parseInt(n2Str);

      // Display square root of each number and of
      //   their sum in console window.
      System.out.println("The square root of " + n1 +
                         " is " + Math.sqrt(n1));
      System.out.println("The square root of " + n2 +
                         " is " + Math.sqrt(n2));
      System.out.println("The square root of their sum is " +
                         Math.sqrt(n1 + n2));
   }
}

