Google Search

Wednesday, October 5, 2011

Ascending order java program


import java.io.*;

import javax.swing.JOptionPane;

class Ascend 

{

public static void main(String[] args) 

{

String name[]={"","",""},temp;

for(int i=0;i<3;i++)

{

name[i]=JOptionPane.showInputDialog("enter name");

}

for(int i=0;i<3;i++)

for(int j=0;j<3;j++)

{

if((name[j].compareTo(name[i]))>0)

{

temp=name[i];

name[i]=name[j];

name[j]=temp;

}

}

}

for(int i=0;i<3;i++)

{

JOptionPane.showMessageDialog(null,name[i],"Message",JOptionPane.INFORMATION_MESSAGE);

}

}

}


0 comments:

Post a Comment