Você está na página 1de 6

LABORATORIO #3

 LÓGICAS PARA ENCONTRAR EL MAYOR Y MENOR EN JAVA

GRUPO 21:

MORENO TOMICHA BETTY CRUZ 213102323

VEDIA ROMERO JOSE DAVID 215166655

ESCALIER SANDOVAL CAROLINA N. 216160650

MEZA RODAS EVELIN 213012219

PORCENTAJE DE AVANCE: 100%

COMENTARIOS:

Para este laboratorio en grupos no se nos complico mucho resolverlo ya


que sabiamos la logica de el anterior practico resuelto en el lenguaje de
visual basic. Para este laboratorio solo tuvimos que cambiar la sintaxis
al lenguaje de java. Grupalmente el lenguaje nos parecio mas sencillo y
facil de utilizar en el nuevo lenguaje que empezamos a programar. Ademas
que dos de nuestros integrantes ya conocian el lenguaje y eso nos resulto
mas rapido para terminar el practico y gracias a esos conocimientos
previos pudieron ayudar a los demas integrantes del grupo.

package javaapplication2;

/**

* @author Estudiante

*/

public class JavaApplication2 {

/**

* @param args the command line arguments

*/

public static void main(String[] args) {

// TODO code application logic here

System.out.println(menorAux3(1, 2, 3));

System.out.println(menorAux4(1, 2, 3, 4));

System.out.println(menorAux5(2, 4, 6, 8, 10));
System.out.println(mayorAux3(3, 6, 9));

System.out.println(mayorAux4(4, 5, 8, 100));

System.out.println(mayorAux5(50, 41, 34, 1000, 78));

System.out.println(menorAnd(5,5,1));

System.out.println(menorAnd(2,5,5,1));

System.out.println(menorAnd(3,2,5,5,1));

System.out.println(mayorAnd(5,5,1));

System.out.println(mayorAnd(2,5,5,1));

System.out.println(mayorAnd(13,2,5,6,10));

System.out.println(menor(9, 5));

System.out.println(menor(8,5,2));

System.out.println(menor(6,5,3,9));

System.out.println(menor(3,6,5,7,8));

System.out.println(mayor(9,6));

System.out.println(mayor(6,3,2));

System.out.println(mayor(6,9,4,5));

System.out.println(mayor(4,8,2,3,9));

// Utilizando variable auxiliar

public static int menorAux3(int a, int b, int c){

int men = a;

if (b < men) men = b;

if (c < men) men = c;

return men;

public static int menorAux4(int a, int b, int c, int d){

int men = a;

if (b < men) men = b;

if (c < men) men = c;

if (d < men) men = d;

return men;
}

public static int menorAux5(int a, int b, int c, int d, int e){

int men = a;

if (b < men) men = b;

if (c < men) men = c;

if (d < men) men = d;

if (e < men) men = e;

return men;

public static int mayorAux3(int a, int b, int c){

int may = a;

if (b > may) may = b;

if (c > may) may = c;

return may;

public static int mayorAux4(int a, int b, int c, int d){

int may = a;

if (b > may) may = b;

if (c > may) may = c;

if (d > may) may = d;

return may;

public static int mayorAux5(int a, int b, int c, int d, int e){

int may = a;

if (b > may) may = b;

if (c > may) may = c;

if (d > may) may = d;

if (e > may) may = e;

return may;

}
// Utilizando operadores lógicos
public static int menorAnd(int a, int b , int c){

if (a < b && a < c) return a;

if (b < c && b < c) return b;

else return c;

public static int menorAnd(int a, int b , int c , int d){

if (a < b && a < c && a < d) return a;

if (b < c && b < c && b < d) return b;

if (c < d && c < d && c < d) return c;

else return d;

public static int menorAnd(int a, int b , int c , int d , int e){

if (a < b && a < c && a < d && a < e) return a;

if (b < c && b < c && b < d && b < e) return b;

if (c < d && c < d && c < d && c < e ) return c;

if (d < a && d < b && d < c && d < e ) return d;

else return e;

public static int mayorAnd(int a, int b , int c){

if (a > b && a > c) return a;

if (b > c && b > c) return b;

else return c;

public static int mayorAnd(int a, int b , int c , int d){

if (a > b && a > c && a > d) return a;

if (b > c && b > c && b > d) return b;

if (c > d && c > d && c > d) return c;

else return d;

public static int mayorAnd(int a, int b , int c , int d , int e){

if (a > b && a > c && a > d && a > e) return a;


if (b > c && b > a && b > d && b > e) return b;

if (c > d && c > b && c > a && c > e ) return c;

if (d > a && d > b && d > c && d > e ) return d;

else return e;

// Utilizando llamadas a otras funciones

public static int menor(int a , int b ){

if (a<b) return a;

else return b;

public static int menor(int a , int b , int c){

return menor(menor(a,b),c);

public static int menor(int a,int b, int c, int d){

return menor(menor(a,b,c),d);

public static int menor(int a, int b, int c, int d, int e){

return menor(menor(a,b,c,d),e);

public static int mayor(int a, int b){

if (a>b) return a;

else return b;

public static int mayor(int a, int b, int c){

return mayor(mayor(a,b),c);

public static int mayor(int a, int b, int c, int d){

return mayor(mayor(a,b,c),d);

public static int mayor(int a, int b, int c, int d, int e){


return mayor(mayor(a,b,c,d),e);

Você também pode gostar