Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

Lv 31,084 points

WitheredGryphon

Favorite Answers35%
Answers106
  • Under Air Force Weight Standards?

    So I'm going in for a physical and I'm about 115 right now and for my height the minimum is 117. Will I fail my physical because of this? How strict are they about underweights?

    4 AnswersMilitary8 years ago
  • C++ Program Problem Needs Correction?

    I have a program (found in the link below):

    http://pastebin.com/mrpHSg5b

    And there's an output error that I can't get to fix. What the program is supposed to do is show the step-by-step process of the Selection Sort. However, instead of swapping the larger number with the first smallest number it finds, it swaps it with the last smallest number it finds. Example:

    Expected:

    1, 5, 2, 3, 8, 6, 4, 6, 9, 4

    1, 2, 5, 3, 8, 6, 4, 6, 9, 4

    1, 2, 3, 5, 8, 6, 4, 6, 9, 4

    1, 2, 3, 4, 8, 6, 5, 6, 9, 4

    1, 2, 3, 4, 4, 6, 5, 6, 9, 8

    1, 2, 3, 4, 4, 5, 6, 6, 9, 8

    1, 2, 3, 4, 4, 5, 6, 6, 9, 8

    1, 2, 3, 4, 4, 5, 6, 6, 9, 8

    1, 2, 3, 4, 4, 5, 6, 6, 8, 9

    Actual:

    1, 5, 2, 3, 8, 6, 4, 6, 9, 4

    1, 2, 5, 3, 8, 6, 4, 6, 9, 4

    1, 2, 3, 5, 8, 6, 4, 6, 9, 4

    1, 2, 3, 4, 8, 6, 4, 6, 9, 5 < ---- Here, instead of swapping the first 4 with the 5, it swaps the last 4.

    1, 2, 3, 4, 4, 6, 8, 6, 9, 5

    1, 2, 3, 4, 4, 5, 8, 6, 9, 6

    1, 2, 3, 4, 4, 5, 6, 6, 9, 8

    1, 2, 3, 4, 4, 5, 6, 6, 9, 8

    1, 2, 3, 4, 4, 5, 6, 6, 8, 9

    Could anyone shed some light on how to fix this?

    2 AnswersProgramming & Design8 years ago
  • Java Prog. Question (Number Format Exception)?

    if (e.getSource() == Calc.eqls) {

    curText = Calc.tf.getText();

    if(curText.contains("*")) {

    if(curText.contains("+")) {

    int add = curText.indexOf("+");

    Calc.tf.setText((curText.substring(add-1)+curText.substring(add+1)));

    }

    else if(curText.contains("-")) {

    int subtr = curText.indexOf("-");

    Calc.tf.setText((curText.substring(subtr-1)+curText.substring(subtr-1)));

    }

    }

    else if(curText.contains("+")) {

    int add = curText.indexOf("+");

    int result = Integer.parseInt(curText.substring(add-1)) + Integer.parseInt(curText.substring(add+1));

    String result2 = Integer.toString(result);

    Calc.tf.setText(result2);

    }

    }

    I'm receiving a number format exception at the below line. I'm trying to make it so that I can take the numbers preceding and succeeding the ' + ' operator, add them together, then reconvert them back to a string so I can output it to the textfield.

    int result = Integer.parseInt(curText.substring(add-1)) + Integer.parseInt(curText.substring(add+1));

    Variables:

    tf = JTextField

    Calc = Main Class

    Rest are self defined.

    Also, debugging it reports that the local variables are unavailable (I'm unsure if this is just a repercussion of a number format exception?)

    Code unedited by yahoo is located at:

    http://pastebin.com/5S4rZGnp

    3 AnswersProgramming & Design9 years ago