import javax.swing.JOptionPane;
import java.text.*;

public class casestudy
{
  public static void main(String[] args)
  {
    JOptionPane.showInputDialog(null, "Program Application", "Choose a Program",
        JOptionPane.QUESTION_MESSAGE, null, new Object[]
        { "Bubble Sorting","Balloon Sorting", "Insertion","Exit" },"casestudy");


    switch(casestudy)
    {case 1:
    {String stno,ndno,rdno,thno,fthno,sthno,vthno,ethno,nthno,tthno;

          stno = JOptionPane.showInputDialog(null, "Input 1st number:");
		  ndno = JOptionPane.showInputDialog(null, "Input 2nd number:");
		  rdno = JOptionPane.showInputDialog(null, "Input 3rd number:");
		  thno = JOptionPane.showInputDialog(null, "Input 4th number:");
		  fthno = JOptionPane.showInputDialog(null, "Input 5th number:");
		  sthno = JOptionPane.showInputDialog(null, "Input 6th number:");
		  vthno = JOptionPane.showInputDialog(null, "Input 7th number:");
		  ethno = JOptionPane.showInputDialog(null, "Input 8th number:");
		  nthno = JOptionPane.showInputDialog(null, "Input 9th number:");
		  tthno = JOptionPane.showInputDialog(null, "Input 10th number:");

	    int i;
	    int array[] = {Integer.parseInt(stno),Integer.parseInt(ndno),Integer.parseInt(rdno),Integer.parseInt(thno),Integer.parseInt(fthno),Integer.parseInt(sthno),Integer.parseInt(vthno),Integer.parseInt(ethno),Integer.parseInt(nthno),Integer.parseInt(tthno)};

	     for(i = 0; i < array.length; i++)
	    JOptionPane.showMessageDialog(null,"Values Before the sort: \n"+array[i]+" ","Input",
	    JOptionPane.INFORMATION_MESSAGE);
	    bubble_srt(array, array.length);
	     for(i = 0; i <array.length; i++)
	    JOptionPane.showMessageDialog(null,"Values after the sort: \n"+array[i]+" ","Result",JOptionPane.INFORMATION_MESSAGE);

}

	 public static void bubble_srt( int a[], int n)
	  {
	    int i, p,t=0;
	    for(i = 0; i < n; i++)
	    {
	      for(p = 1; p < (n-i); p++)
	      {
	        if(a[p-1] > a[p])
	        {
	          t = a[p-1];
	          a[p-1]=a[p];
	          a[p]=t;
		    }
	      }
	    }

	}
}
     case 2:
     System.out.println("wla pa");
     case 3:


	    int t;

		JOptionPane.showMessageDialog(null, "\tThis program will accept 5 inputs from you.", "\tInsertion", JOptionPane.INFORMATION_MESSAGE);

	    String stno,ndno,rdno,thno,fthno;

			stno = JOptionPane.showInputDialog(null, "Input 1st number:");
			ndno = JOptionPane.showInputDialog(null, "Input 2nd number:");
			rdno = JOptionPane.showInputDialog(null, "Input 3rd number:");
			thno = JOptionPane.showInputDialog(null, "Input 4th number:");
			fthno = JOptionPane.showInputDialog(null, "Input 5th number:");

		int array[] = {Integer.parseInt(stno),Integer.parseInt(ndno),Integer.parseInt(rdno),Integer.parseInt(thno),Integer.parseInt(fthno)};

	    for(t = 0; t < array.length; t++)
	    {
			JOptionPane.showMessageDialog(null, array[t]+"  ", "Values before sorting.", JOptionPane.INFORMATION_MESSAGE);
	  	}

	{
	    for (int i = 1; i < 5; i++)
	    {
	      int j = i;
	      int B = array[i];
	      while ((j > 5) && (array[j-1] > B))
	      {
	        array[j] = array[j-1];
	        j--;
	      }
	      array[j] = B;

	  }
	    for(t = 0; t < 5; t++)
	    {
		JOptionPane.showMessageDialog(null, array[t]+"  ", "Values after sorting.", JOptionPane.INFORMATION_MESSAGE);
		}
	}


  }
}

=====>this function "public static void bubble_srt( int a[], int n)"

is this right?

Use code tags and post only relevant code.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.