Answer to Question #30583 in Java | JSP | JSF for nittya
2013-05-16T09:59:12-04:00
import java.io.*;
import java.util.Scanner;
class userinput {
public static void main(String args[])
throws IOException
{
Scanner s=new Scanner(System.in);
String[]a=new String[4];
System.out.println("Enter 'STOP' to quit.");
for(int i=0;i<4;i++)
{
System.out.println(i+1+".Enter your input:");
String temp=s.nextLine();
a[i]=temp;
}
{
Scanner in = new Scanner(System.in);
String str[] = new String[4];
System.out.println("Enter 'STOP' to quit.");
for(int i=0; i<4; i++) {
str[i] = in.next();
if(str[i].equals("stop")) break;
System.out.println(str[i]);
System.out.println(a[i]);
}
System.out.println("**************");
System.out.println(" RESULT ");
System.out.println("**************");
for(int i=0;i<4;i++)
{
for(int j=0;j<4;j++)
{
String temp=a[i];
String tempB=a[j];
if(temp.compareTo(tempB)<0)
{
a[i]=tempB;
a[j]=temp;
}
}
}
for(int i=0;i<4;i++)
{
System.out.println(a[i]);
1
2013-05-17T09:41:11-0400
Dear visitor Unfortunately, the statement of your question is a bit confusing. What do you need to be done? Please, give us the details so we could help you
Need a fast expert's response?
Submit order
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS !
Learn more about our help with Assignments:
Java JSP JSF
Comments
Leave a comment