UNA HERMOSA MOTO

UNA HERMOSA MOTO

miércoles, 22 de abril de 2015

Problema Propuesto 15


15.- Dado 03 números, devolver los números ordenados en forma ascendente y descendente.



/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package propuesto015;
import java.util.Scanner;
/**
 *
 * @author abel montalvan
 */
public class Propuesto015 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
     int a,b,c,Ma=0,I=0,Me=0;
                       
            Scanner teclado=new Scanner(System.in);
            System.out.print("PRIMER NÚMERO:");
            a=teclado.nextInt();
            System.out.print("SEGUNDO NÚMERO:");
            b=teclado.nextInt();
            System.out.print("TERCER NÚMERO:");
            c=teclado.nextInt();
           
           
            if (a>b && a>c){
                  Ma=a;
            }else{
            if (b>a && b>c){
                  Ma=b;
            }else{
                  Ma=c;
            }
            }
            if(a<b &&a<c){
                  Me=a;
            }else{
            if (b<a&&b<c){
                  Me=b;
            }else{
                  Me=c;
                  }
            }
            I=(a+b+c)-(Ma + Me);
          
            
            System.out.println("");
            System.out.println("ORDEN DESCENDENTE: ");
            System.out.println("MAYOR: "+Ma);
            System.out.println("INTERMEDIO: "+I);
            System.out.println("MENOR: "+Me);
            System.out.println("ORDEN ASCENDENTE: ");
            System.out.println("MENOR: "+Me);
            System.out.println("INTERMEDIO: "+I);
            System.out.println("MAYOR: "+Ma);
      }
}

No hay comentarios:

Publicar un comentario