Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #29614
| From | Jeff Higgins <jeff@invalid.invalid> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Help with java insertion sort program |
| Date | 2014-08-10 05:54 -0400 |
| Organization | A noiseless patient Spider |
| Message-ID | <ls7fh9$4ns$1@dont-email.me> (permalink) |
| References | <ls6k6e$v0r$1@dont-email.me> <ls6lcd$5nm$1@dont-email.me> <ls6p9j$v7a$1@dont-email.me> <ls6r8g$694$1@dont-email.me> <ls6shk$c40$1@dont-email.me> |
On 08/10/2014 12:30 AM, Jeff Higgins wrote:
> On 08/10/2014 12:11 AM, Scott Dunning wrote:
>> Ok so I realized that I was not filling the array with anything but now
>> I'm having issues filling it correctly. It's only filling the array
>> with three of the user inputs and I just cannot figure out why....
>
> I thought you had that sorted over at stackoverflow.
> I must have misread that too.
>
> Please, PLEASE, use java.io.Console class. It makes joy.
> If your Professor disallows it, understand him as saying:
> "F**k me runnin'."
>
Huh, some Java IDEs understand Console the same way!
School begins Monday for our local grade-schoolers,
are you sure you're in a summer class?
import javax.swing.JOptionPane;
public class DriverSort {
public static void main(String[] args) {
Object[] sorts = {"Insertion", "Selection", "Bubble"};
String sortString = (String)JOptionPane.showInputDialog(
null,
"Select a sort algorithm\nCancel quits the program",
"Sort Algorithm Selector",
JOptionPane.PLAIN_MESSAGE,
null,sorts,"Insertion");
if(sortString == null) {
System.exit(1);
} else if(sortString != "Insertion"){
JOptionPane.showMessageDialog(
null, "Selection and Bubble sorts are not implemented");
System.exit(2);
}
String arrayString = (String)JOptionPane.showInputDialog(
null,
"Enter a space separated list of integers\nCancel quits the
program",
"The Array to Sort"
,JOptionPane.PLAIN_MESSAGE,null,null,"");
if(arrayString == null) {
System.exit(3);
}
try {
String[] stringArray = arrayString.split(" ");
int[] input = new int[stringArray.length];
for (int i = 0; i < stringArray.length; i++) {
input[i] = Integer.parseInt(stringArray[i]);
}
Sorter.insertionSort(input);
Sorter.printArray(input);
} catch (NumberFormatException e) {
JOptionPane.showMessageDialog(
null, "Could not parse a list of integers");
System.exit(4);
}
}
}
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Help with java insertion sort program Scott Dunning <scottwd01@gmail.com> - 2014-08-09 19:11 -0700
Re: Help with java insertion sort program Jeff Higgins <jeff@invalid.invalid> - 2014-08-09 22:28 -0400
Re: Help with java insertion sort program Jeff Higgins <jeff@invalid.invalid> - 2014-08-09 23:34 -0400
Re: Help with java insertion sort program Scott Dunning <scottwd01@gmail.com> - 2014-08-09 21:11 -0700
Re: Help with java insertion sort program Jeff Higgins <jeff@invalid.invalid> - 2014-08-10 00:30 -0400
Re: Help with java insertion sort program Jeff Higgins <jeff@invalid.invalid> - 2014-08-10 00:45 -0400
Re: Help with java insertion sort program Jeff Higgins <jeff@invalid.invalid> - 2014-08-10 05:58 -0400
Re: Help with java insertion sort program Jeff Higgins <jeff@invalid.invalid> - 2014-08-10 05:54 -0400
Re: Help with java insertion sort program Mike Amling <mamling@chaff.us> - 2014-08-10 06:09 -0500
Re: Help with java insertion sort program Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-08-10 07:43 -0400
Re: Help with java insertion sort program Mike Amling <mamling@chaff.us> - 2014-08-13 23:51 -0500
Re: Help with java insertion sort program Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-08-14 08:07 -0400
Re: Help with java insertion sort program Mike Amling <mamling@chaff.us> - 2014-08-14 00:46 -0500
Re: Help with java insertion sort program Arne Vajhøj <arne@vajhoej.dk> - 2014-08-19 16:50 -0400
Re: Help with java insertion sort program Roedy Green <see_website@mindprod.com.invalid> - 2014-08-12 03:00 -0700
Re: Help with java insertion sort program Mike Amling <mamling@chaff.us> - 2014-08-13 23:51 -0500
Re: Help with java insertion sort program Jukka Lahtinen <jtfjdehf@hotmail.com.invalid> - 2014-08-14 14:30 +0300
csiph-web