Advertisement
khalil_abulail99

Untitled

Mar 26th, 2019
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.20 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Demo{
  4.    
  5.    
  6.     public static void main(String[] args) {
  7.         // TODO code application logic here
  8.        
  9.         // Variables for user Input
  10.         int a , b , c , d , e ;
  11.         // Variables to be found
  12.         int min_integer = 0,mid_low_integer = 0,mid_integer = 0,mid_high_integer = 0,max_integer = 0;
  13.        
  14.         // Reading Five integers from console screen
  15.         Scanner sc = new Scanner(System.in);
  16.  
  17.         System.out.println("Please enter five integers in a row");
  18.  
  19.         a = sc.nextInt();
  20.         b = sc.nextInt();
  21.         c = sc.nextInt();
  22.         d = sc.nextInt();
  23.         e = sc.nextInt();
  24.        
  25.        // Your code goes here
  26.        max_integer = Math.max( a, ( Math.max ( b , Math.max ( c , Math.max ( d , e ) ) ) ) )  ;
  27.        min_integer =  Math.min ( a, ( Math.min ( b , Math.min ( c , Math.min ( d , e ) ) ) ) )  ;
  28.        mid_high_integer = Math.min( Math.max(Math.max(Math.max(a,b),Math.max(b,c)),Math.max(Math.max(b,c),Math.max(c,d))) ,
  29. Math.min(Math.max(Math.max(Math.max(b,c),Math.max(c,d)),Math.max(Math.max(c,d),Math.max(d,e))),Math.min(Math.max(Math.max(Math.max(c,d),Math.max(d,e)),Math.max(Math.max(d,e),Math.max(e,a))),Math.min(Math.max(Math.max(Math.max(d,e),Math.max(e,a)),Math.max(Math.max(e,a),Math.max(a,b))),Math.max(Math.max(Math.max(e,a),Math.max(a,b)),Math.max(Math.max(a,b),Math.max(b,c)))))) );
  30.        mid_low_integer = Math.max( Math.min(Math.min(Math.min(a,b),Math.min(b,c)),Math.min(Math.min(b,c),Math.min(c,d))) , Math.max(Math.min(Math.min(Math.min(b,c),Math.min(c,d)),Math.min(Math.min(c,d),Math.min(d,e))),Math.max(Math.min(Math.min(Math.min(c,d),Math.min(d,e)),Math.min(Math.min(d,e),Math.min(e,a))),Math.max(Math.min(Math.min(Math.min(d,e),Math.min(e,a)),Math.min(Math.min(e,a),Math.min(a,b))),Math.min(Math.min(Math.min(e,a),Math.min(a,b)),Math.min(Math.min(a,b),Math.min(b,c)))))) );
  31.        mid_integer = a + b + c + d + e  - max_integer - mid_high_integer - min_integer - mid_low_integer ;
  32.        // to Here
  33.        
  34.         // Printing out the result -- Sorted Array
  35.         System.out.println(min_integer + " " + mid_low_integer + " " + mid_integer + " " + mid_high_integer + " " + max_integer);
  36.     }
  37.    
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement