Skip to content

Instantly share code, notes, and snippets.

@Hulzenga
Last active August 29, 2015 13:56
Show Gist options
  • Save Hulzenga/9181942 to your computer and use it in GitHub Desktop.
Save Hulzenga/9181942 to your computer and use it in GitHub Desktop.
public static void main(String[] args) {
String initialInput;
String patternA;
String patternB;
int response;
int contA, contB, contC;
boolean success = false;
while (!success) {
JOptionPane.showMessageDialog(null, "The purpose of this script is to " +
"give the value of X from a quadratic equation.\nThe equation" +
" must have 3 constants and be in this format:\nAX^2(+/-)" +
"BX(+/-)C\n\nThe constant A cannot equal 0." +
"\n\nYou will be prompted for 3 integers, and you want to add" +
"or subtract them. You may use negative numbers.");
initialInput = JOptionPane.showInputDialog("What is your integer for X^2?");
patternA = "[0-9]|-|";
if (initialInput.matches(patternA) == true) {
contA = Integer.parseInt(initialInput);
success = true;
} else {
JOptionPane.showMessageDialog(null, "That was not an integer. Please try" + " again."); ///////////I WANT TO RETURN FROM HERE } System.exit(0);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment