Showing posts with label codings. Show all posts
Showing posts with label codings. Show all posts
Sunday, 30 March 2014
Java Programs - Alphabetical order of the given Name
Alphabetical order of the given Name
Program Name:- alpha.java
import java.io.*;
import java.lang.*;
class alpha
{
public static void main(String args[])throws IOException
{
String a[]=new String[10];
String b;
int n;
DataInputStream in=new DataInputStream(System.in);
System.out.print("\nEnter the Number of name :");
n=Integer.parseInt(in.readLine());
for(int i=0;i<n;i++)
{
a[i]=in.readLine();
}
for(int i=0;i<n;i++)
{
for(int j=i+1;j<n;j++)
{
if(a[i].compareTo(a[j])<0)
{
b=a[i];
a[i]=a[j];
a[j]=b;
}
}
}
System.out.println("\n Alphabetical order of name is:");
for(int i=0;i<n;i++)
{
System.out.println(a[i]);
}
}
}
Labels:
-,
Alphabetical,
codings,
Errors,
errors000,
given,
java,
java code,
java programs,
Java Programs - Alphabetical order of the given Name,
Name,
of,
order,
PROGRAMS,
source code,
the,
using,
w3 java,
w3 schools
Subscribe to:
Posts (Atom)