import javax.swing.*;

/** a class that does simple math on values supplied by the user */
public class MyMath {

  /** Prompt the user for two integers and return the sum */
  public static int addIntegers() {

    String num1 = JOptionPane.showInputDialog("Please enter an integer");
    String num2 = JOptionPane.showInputDialog("Please enter an integer");

    int num1int = Integer.parseInt(num1);
    int num2int = Integer.parseInt(num2);

    return num1int + num2int;
  }

  /** Prompt the user for two integers and return the sum.
   *  Note that this is the same as addIntegers(), but with
   *  no variables.  The rest of the methods in this class could
   * be re-written the same way.                            */
  public static int addIntegers2() {
    return Integer.parseInt(JOptionPane.showInputDialog("Enter an int"))
       + Integer.parseInt(JOptionPane.showInputDialog("Enter an int"));
  }

  /** Prompt the user for two doubles and return the sum */
  public static double addDoubles() {

    String num1 = JOptionPane.showInputDialog("Please enter any number");
    String num2 = JOptionPane.showInputDialog("Please enter any number");

    return Double.parseDouble(num1) + Double.parseDouble(num2);
  }

  /** Prompt the user for two doubles and return the sum */
  public static boolean doublesEqual() {

    String num1 = JOptionPane.showInputDialog("Please enter any number");
    String num2 = JOptionPane.showInputDialog("Please enter any number");

    return Double.parseDouble(num1) == Double.parseDouble(num2);
  }

  /** Prompt the user for a double and an int and return whether they
   *  are equal.
   */
  public static boolean intAndDoubleEqual() {

    String num1 = JOptionPane.showInputDialog("Please enter any number");
    String num2 = JOptionPane.showInputDialog("Please enter an integer");

    return Double.parseDouble(num2) == Integer.parseInt(num1);
  }

}
