shawonrog

ascending

Feb 19th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. import java.util.Arrays;
  2. import java.util.Scanner;
  3. public class accending{
  4. public static void main(String[] args) {
  5.  
  6. Scanner sc = new Scanner(System.in);
  7. int[] A = new int[3];
  8. for(int i=0;i<2;i++)
  9. {
  10. A[i]= sc.nextInt();
  11.  
  12. }
  13.  
  14. Arrays.sort(A);
  15. System.out.print("Numbers in Ascending Order:" );
  16. for(int i = 0; i < 3; i++){
  17. System.out.print( " " + A[i]);
  18. }
  19. System.out.print("Numbers in Descending Order: " );
  20. for(int i = A.length - 1; i >= 0; i--){
  21. System.out.print( " " + A[i]);
  22. }
  23.  
  24.  
  25.  
  26. }
  27.  
  28. }
Add Comment
Please, Sign In to add comment