Answer to Question #30583 in Java | JSP | JSF for nittya

Question #30583
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
Expert's answer
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!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS