Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //newest
- public static void main( String[] args ) {
- Scanner user_input = new Scanner(System.in);
- long radicand = 0;
- long[] rads;
- boolean isNegative = false, consoleInput = false;
- try {
- radicand = Long.parseLong(args[0]);
- consoleInput = true;
- }
- catch (ArrayIndexOutOfBoundsException e) { }
- catch (NumberFormatException e2) {
- System.out.print("That wasn't an integer. ");
- }
- if (consoleInput == false) {
- radicand = Prompt.integer("Please enter the current radicand");
- }
- if (radicand < 0) {
- radicand = -radicand;
- isNegative = true;
- }
- rads = simplify(radicand);
- System.out.println(display(radicand, rads[0], rads[1], isNegative));
- }
- //new
- public static void main( String[] args ) {
- Scanner user_input = new Scanner(System.in);
- long radicand = INPUT_FAILURE;
- long[] rads;
- boolean isNegative = false;
- try {
- radicand = Long.parseLong(args[0]);
- }
- catch (ArrayIndexOutOfBoundsException e) { }
- catch (NumberFormatException e2) {
- System.out.print("That wasn't an integer. ");
- }
- while (radicand == INPUT_FAILURE) {
- radicand = Prompt.integer("Please enter the current radicand");
- }
- if (radicand < 0) {
- radicand = -radicand;
- isNegative = true;
- }
- rads = simplify(radicand);
- System.out.println(display(radicand, rads[0], rads[1], isNegative));
- }
- //old
- public static void main( String[] args ) {
- Scanner user_input = new Scanner(System.in);
- long radicand = INPUT_FAILURE;
- long[] rads;
- boolean isNegative = false;
- try {
- radicand = Long.parseLong(args[0]);
- }
- catch (ArrayIndexOutOfBoundsException e) { }
- catch (NumberFormatException e2) {
- System.out.print("That wasn't an integer. ");
- }
- while (radicand < 0) {
- System.out.print("Please enter the current radicand: ");
- try {
- radicand = Long.parseLong(user_input.next());
- }
- catch (NumberFormatException e) {
- System.out.print("That's not an integer! ");
- radicand = INPUT_FAILURE;
- continue;
- }
- if (radicand < 0) {
- radicand = -radicand;
- isNegative = true;
- }
- }
- rads = simplify(radicand);
- System.out.println(display(radicand, rads[0], rads[1], isNegative));
- }
Advertisement
Add Comment
Please, Sign In to add comment