package class4_1_CheckingJOptionPane; // Josiah Yoder, MSOE, 28 September 2015 import javax.swing.*; import java.util.Scanner; public class CheckingJOptionPane { public static void main(String[] args) { String numberStr = ""; boolean goodStr = false; Scanner stringScanner = null; while(numberStr != null && !goodStr) { numberStr = JOptionPane.showInputDialog("Welcome to the Square-root computer.\nPlease enter a number: "); if(numberStr != null) { stringScanner = new Scanner(numberStr); goodStr = stringScanner.hasNextDouble(); } } if(numberStr == null) { JOptionPane.showMessageDialog(null,"Thank you for using the program."); } else { double number = stringScanner.nextDouble(); double root = Math.sqrt(number); // What to put here? JOptionPane.showMessageDialog(null, "The square root is: " + root); } } }