Write a program that prompts the user to input three numbers.

The program should then output numbers in ascending order.

Questions by qwerty0605

Showing Answers 1 - 0 of 0 Answers

Rashmi

  • Jan 22nd, 2012
 

Code
  1. import java.io.*;

  2. import java.util.*;

  3.  

  4. public class ((class name here)) {

  5.  

  6. public static void main(String[] args) {

  7. Scanner q=new Scanner(System.in);

  8. System.out.println("Input three numbers");

  9. int i[] = new int[3];

  10. i[0]=q.nextInt();

  11. i[1]=q.nextInt();

  12. i[2]=q.nextInt();

  13. Arrays.sort(i);

  14. System.out.println(i[0]+","+i[1]+","+i[2…

  15. }

  16.  

  17. }

  Was this answer useful?  Yes

NARESH KUMAR

  • Feb 3rd, 2012
 

Code syntax is:-

Code
  1.  

  2. import java.util.Scanner;

  3. public class A{

  4.  

  5. public static void main(String[] args){

  6. Scanner scanner=new Scanner (System.in);

  7. int v1=s.nextInt();//value 1st

  8. int v2=s.nextint();//value 2nd

  9. int v3=s.nextInt();//value 3rd

  10. }//end of main method

  11. }// end of class

  Was this answer useful?  Yes

vishnu

  • Feb 24th, 2012
 


import java.util.Iterator;
import java.util.Scanner;
import java.util.SortedSet;
import java.util.TreeSet;


public class ascend {

static int i=0;
public static void main(String[] args)
{
SortedSet elements = new TreeSet();
for(int j=0;j<3;j++)
{
Scanner sc=new Scanner(System.in);
i=sc.nextInt();
elements.add(i);
}
Iterator iter = elements.iterator();
while (iter.hasNext()) {
System.out.println("Element in set is --> "+iter.next());
}}}

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions