Universidad Autónoma Gabriel Rene Moreno Facultad
De Ingeniería Y Ciencias De La Computación Y
Telecomunicaciones
PROGRAMACIÓN I
CONTENIDO:
• FUNCIONES LÓGICAS EN JAVA Y PYTHON
PORCENTAJE TERMINADO: 100%.
GRUPO: 14
Integrantes DT HG HI EVAL
Claros Aguirre Bianca Sofia 0 0 0 0
Copa Monzon Dalessandro 2 1 6 85
Copatiti Acapa Jessica Noemi 2 1 5 90
Cordero Mamani Javier 2 1 10 90
Coronel Callisaya Mirko David 1 1 2 60
Cotjire Riero Elkin Joel 2 1 5 51
Fecha de Presentación: lunes, 6 de febrero de 2023
Fecha Presentada: lunes, 6 de febrero de 2023
Días de Retraso: 0
Lenguaje PYTHON en VSC
"""//////////////// Numero impar y Par /////////////"""
def par(a):
return (a % 2 ==0)
#print (par(9))
def Impar(a):
return not par(a)
#print (Impar(10))
"""/////// Dos Pares /////"""
def DosP2(a,b):
return par(a) and par(b)
#print(DosP2(3,1))
def DosP3(a,b,c):
return (DosP2(a,b) and Impar(c)) or (DosP2(a,c) and Impar(b)) or (DosP2(b,c)and Impar(a))
#print (DosP3(1,8,4))
def DosP4(a,b,c,d):
return(DosP3(a,b,c) and Impar(d)) or (DosP3(b,c,d) and Impar(a)) or (DosP3(c,d,a) and
Impar(b)) or (DosP3(a,b,d) and Impar(c))
#print(DosP4(7,8,1,9))
def DosP5(a,b,c,d,e):
return (DosP4(a,b,c,d) and Impar (e)) or (DosP4(a,b,c,e) and Impar (d)) or () or
(DosP4(a,b,e,d) and Impar (c)) or (DosP4(a,c,e,d) and Impar (b)) or (DosP4(c,b,e,d) and Impar
(a))
#print(DosP5(1,2,3,9,5))
"""//////////// Tres Pares ////////"""
def TresP3(a,b,c):
return par(a) or par(b) or par(c)
#print (TresP3(3,1,9))
def TresP4(a,b,c,d):
return TresP3(a,b,c) or par(d)
#print(TresP4(1,7,9,5))
def TresPar5(a,b,c,d,e):
return TresP4(a,b,c,d) or par(e)
#print(TresPar5(90,7,7,1,5))
"""/////////Existe un par"""
def ExisPar2(a,b):
return par(a) or par(b)
#print(ExisPar2(1,7))
def ExisP3(a,b,c):
return ExisPar2(a,b) or par(c)
#print(ExisP3(7,1,2))
def ExisP4(a,b,c,d):
return (ExisP3(a,b,c) or par(d))
#print(ExisP4(7,9,1,5))
def ExisP5(a,b,c,d,e):
return ExisP4(a,b,c,d) or par(e)
#print (ExisP5(1,7,9,5,3))
"""//////// Existe Impar /////////"""
def ExisImpar2(a,b):
return Impar(a) or Impar(b)
#print(ExisImpar2(10,8))
def ExisImpar3(a,b,c):
return ExisImpar2(ExisImpar2(a,b), Impar(c))
#print(ExisImpar3(8,4,2))
def ExisteImpar4(a,b,c,d):
return ExisImpar2(ExisImpar2(a,b),ExisImpar2(c,d))
#print(ExisteImpar4(2,4,8,9))
def ExisImpar5(a,b,c,d,e):
return Impar(a) or Impar(b) or Impar(c) or Impar(d) or Impar(e)
#print(ExisImpar5(20,40,81,44,80))
"""///// Todos los argumentos son pares ////"""
def TodosPar2(a,b):
return par(a) and par(b)
#print(TodosPar2(8,1))
def TodosPar3(a,b,c):
return TodosPar2(a,b) and par(c)
#print (TodosPar3(1,4,6))
def TodosPares4(a,b,c,d):
return TodosPar3(a,b,c) and par(d)
#print(TodosPares4(2,2,4,8))
def TodosPares5(a,b,c,d,e):
return TodosPares4(a,b,c,d) and par(e)
#print(TodosPares5(2,4,8,6,90))
"""///// Todos los argumentos son pares ////"""
def TodosIm2(a,b):
return Impar(a) and Impar(b)
#print(TodosIm2(1,5))
def TodosIm3(a,b,c):
return TodosIm2(a,b) and (not par(c))
#print(TodosIm3(1,5,7))
def TodosIm4(a,b,c,d):
return TodosIm2(a,b) and TodosIm2(c,d)
#print(TodosIm4(1,2,4,3))
#////// Impar y Par
def Ambos2(a,b):
return ExisImpar2(a,b) and ExisPar2(a,b)
#print(Ambos2(7,10))
def Ambos3(a,b,c):
return ExisImpar3(a,b,c) and ExisP3(a,b,c)
#print(Ambos3(1,3,5))
def Ambos4(a,b,c,d):
return ExisImpar2 (ExisImpar3(a,b,c),d) and ExisPar2(ExisImpar3(a,b,c),d)
#print(Ambos4(9,7,1,78))
def Ambos5(a,b,c,d,e):
return ExisImpar5(a,b,c,d,e) and ExisP5(a,b,c,d,e)
#print(Ambos5(1,7,10,5,3))
"""////// Alterno ////"""
def Alt2(a,b):
return (Ambos2(a,b))
#print(Alt2(1,4))
def Alt3(a,b,c):
return (par(a) and Impar(b) and par(c)) or (Impar(a) and par(b) and Impar(c))
#print (Alt3(2,5,70))
def Alt4(a,b,c,d):
return Alt2(Alt3(a,b,c),d)
#print(Alt4(1,5,3,4))
def alt5(a,b,c,d,e):
return (par(a) and Impar(b) and par(c) and Impar(d) and par(e)) or (Impar(a) and par(b)
and Impar(c) and par(d) and Impar(e))
#print(alt5(1,2,3,4,8))
#///// Iguales
def Iguales2(a,b):
return a == b
#print(Iguales2(7,8))
def iguales3(a,b,c):
return a == b == c
#print(iguales3(7,7,4))
def iguales4(a,b,c,d):
return a==b and a==c and a==d and b==c and b==d and c==d
#print(iguales4(1,8,1,1))
def Iguales5(a,b,c,d,e):
return Iguales2(iguales4(a,b,c,d),e)
#print(Iguales5(1,1,1,8,1))
"""///// Diferentes ////"""
def difere(a,b):
return a!=b
#print (difere2(7,4))
def Difere3(a,b,c):
return a != b and a!= c and b!=c
#print( Difere3(1,8,1))
def Difere4(a,b,c,d):
return a != b and a!= c and b!=c and a!=d and b!=d and c!=d
#print(Difere4(4,7,87,7))
def Difere5(a,b,c,d,e):
return a != b and a!= c and a!=d and a!=e and b!=c and b!=d and b!=e and c!=d and c!= e
#print(Difere5(4,1,8,5,1))
""" ///// Dos iguales /////"""
def DosIg2(a,b):
return Iguales2(a,b)
#print(DosIg2(7,8))
def dosIguales3(a,b,c):
return DosIg2(a,b) and b!=c
def DosIg3(a,b,c):
return dosIguales3(a,b,c) or dosIguales3(a,c,b) or dosIguales3(b,c,a)
#print(DosIg3(1,8,1))
def dosiguales4(a,b,c,d):
return DosIg2(a,b) and c!=a and d!=a
def DosIg4(a,b,c,d):
return dosiguales4(a,b,c,d) or dosiguales4(a,c,b,d) or dosiguales4(a,d,b,c) or
dosiguales4(b,c,a,d) or dosiguales4(b,d,a,c) or dosiguales4(c,d,a,b)
#print (DosIg4(1,1,1,8))
def Dosiguales5(a,b,c,d,e):
return DosIg2(a,b) and a!=c and a!=d and a!=e
def DosIg5(a,b,c,d,e):
return Dosiguales5(a,b,c,d,e) or Dosiguales5(a,c,d,b,e) or Dosiguales5(a,d,b,c,e) or
Dosiguales5(a,e,b,c,d) or Dosiguales5(b,c,a,d,e) or Dosiguales5(b,d,a,c,e) or
Dosiguales5(b,e,a,c,d) or Dosiguales5(c,d,a,b,e) or Dosiguales5(c,e,a,b,d) or
Dosiguales5(d,e,a,b,c)
#print(DosIg5(7,8,24,7,7))
"""///// Tres Iguales ////"""
def TresIg3(a,b,c):
return iguales3(a,b,c)
#print(TresIg3(1,1,5))
def TresIg4(a,b,c,d):
return (TresIg3(a,b,c) and a!=d) or (TresIg3(a,c,d)and a!=b) or (TresIg3(a,b,d)and a!=c)
or (TresIg3(b,c,d) and b!=a)
#print(TresIg4(8,8,8,8))
def TresIg5(a,b,c,d,e):
if TresIg3(a,b,c) and Difere3(a,d,e): return True
if TresIg3(d,b,c) and Difere3(a,b,e): return True
if TresIg3(c,d,e) and Difere3(a,d,b): return True
if TresIg3(a,b,e) and Difere3(c,d,e): return True
if TresIg3(a,e,c) and Difere3(d,b,e): return True
if TresIg3(d,b,e) and Difere3(a,c,e): return True
if TresIg3(a,d,e) and Difere3(a,c,b): return True
if TresIg3(e,b,c) and Difere3(a,d,e): return True
if TresIg3(a,b,d) and Difere3(e,c,d): return True
else: return False
#print(TresIg5(7,7,7,7,7))
"""///// Ordenado de manera Ascendente ////"""
def SecuenciaAc2(a,b):
return b > a
#print(SecuenciaAc2(8,4))
def SecuenciaAsc3(a,b,c):
return SecuenciaAc2(a,b) and SecuenciaAc2(b,c)
#print(SecuenciaAsc3(8,2,3))
def SecuenciaAsc4(a,b,c,d):
return SecuenciaAsc3(a,b,c) and d>c
#print (SecuenciaAsc4(2,8,81,90))
def SecuenciaAsc5(a,b,c,d,e):
return SecuenciaAsc4(a,b,c,d) and e>d
#print(SecuenciaAsc5(1,2,50,9,10))
"""///// Ordenado de manera Descendente ////"""
def SecuenciaDesc2(a,b):
return not SecuenciaAc2(a,b)
#print(SecuenciaDesc2(1,4))
def SecuenciaDesc3(a,b,c):
return a>b and b>c and a>c
#print(SecuenciaDesc3(7,9,1))
def SecuenciaDesc4(a,b,c,d):
return a>b and a>c and a>d and b>c and b>d and c>d
#print(SecuenciaDesc4(80,70,59,20))
def SecuenciaDesc5(a,b,c,d,e):
return a>b and a>c and a>d and a>e and b>c and b>d and c>d
#print(SecuenciaDesc5(5,4,3,20,1))
"""///// Palidrome /////"""
def Palindrome2(a,b):
return Iguales2(a,b)
#print(Palindrome2(2,7))
def Palindrome3(a,b,c):
return Iguales2(a,c)
#print(Palindrome3(17,1,1))
def Palindrome4(a,b,c,d):
return Iguales2(a,d) and Iguales2(b,c)
#print(Palindrome4(2,1,5,2))
def Palindrome5(a,b,c,d,e):
return Iguales2(a,e) and Iguales2(b,d)
#print(Palindrome5(7,8,4,9,7))
"""//////// POKER ////////"""
def Poker2(a,b):
return difere(a,b)
#print(Poker2(7,7))
def Poker3(a,b,c):
return DosIg3(a,b,c)
#print(Poker3(7,1,7))
def Poker4(a,b,c,d):
return TresIg4(a,b,c,d)
#print(Poker4(8,8,2,8))
def Poker5(a,b,c,d,e):
if iguales4(a,b,c,d) and a!=e: return True
if iguales4(a,b,c,e) and a!=d: return True
if iguales4(b,c,d,e) and b!=a: return True
if iguales4(c,d,a,e) and c!=b: return True
if iguales4(a,b,d,e) and a!=c: return True
else: return False
#print(Poker5(8,21,6,4,4))
"""/////// Suma que es igual a algun argumento ///////"""
def Sumandos2(a,b):
return (a+b) == a or (a+b) == b
#print(Sumandos2(2,0))
def Sumandos3(a,b,c):
return(a+b+c) == a or (a+b+c) == b or (a+b+c) == c
#print(Sumandos3(6,0,0))
def Sumandos4(a,b,c,d):
return (a+b+c+d) == a or (a+b+c+d) == b or (a+b+c+d) == c or (a+b+c+d) == d
#print(Sumandos4(7,4,1,0))
def Sumandos5(a,b,c,d,e):
return (a+b+c+d+e) == a or (a+b+c+d+e) == b or (a+b+c+d+e) == c or (a+b+c+d+e) == d or
(a+b+c+d+e) == e
#print(Sumandos5(1,2,8,0,0))
"""////// Division Entera /////"""
def DivEntera3(a,b,c):
return(a // b == c) or (a // c == b) or (b // c == a) or (b // a == c) or (c // a ==b) or
(c // b==a)
#print(DivEntera3(15,3,5))
def Div(a,b,c,d):
return (a // b == c) or (a // b == d) or (b//a == c) or ( b // a == d)
def DivEnter4(a,b,c,d):
return Div(a,b,c,d) or Div(c,d,a,b) or Div(a,c,b,d) or Div(d,c,b,a) or Div(d,a,b,c) or
Div(b,a,d,c)
#print(DivEnter4(5,20,10,2))
"""///// Positivo y Negativo/////"""
def Positivo(a):
return a>0 and a!=0
#print(Positivo(7))
def Positivo2(a,b):
return Positivo(a) and Positivo(b)
#print(Positivo2(-1,4))
def Positvo3(a,b,c):
return Positivo(a) and Positivo(b) and Positivo (c)
#print(Positvo3(2,8,3))
"""----------------------------"""
def Negativo (a):
return a<0 and a!=0
#print(Negativo(0))
def Negativo2(a,b):
return Negativo(a) and Negativo(b)
#print(Negativo2(-1,-8))
def Negativo3(a,b,c):
return Negativo(a) and Negativo(b) and Negativo(c)
#print(Negativo3(-7,5,8))
def UnDigPos(n):
if Positivo(n) and ( n // 10 ==0): return True
else: return False
#print(UnDigPos(2087))
def UnDigNeg(n):
if Negativo(n) and ( n // 10 ==0): return True
else: return False
#print(UnDigNeg(-4))
def DosDigPos(a):
return Positivo(a) and (a // 10 > 0)
#print(DosDigPos(54))
def DosDigPos2(a,b):
return Positivo2(a,b) and (a // 10 >0) and ( b // 10 > 0)
#print(DosDigPos2(80,1))
def DosDigPos3(a,b,c):
return DosDigPos2(a,b) and DosDigPos(c)
#print(DosDigPos3(7,1,5))
"""----------------------- Negativo-------------------------"""
def DosDigNeg(a):
return Negativo(a) and (a // 10 > 0)
#print(DosDigNeg(-74))
def DosDigNeg2(a,b):
return Negativo2(a,b) and a <-9 and b < -9
#print(DosDigNeg2(-17,-25))
def DosDigNeg3(a,b,c):
return Negativo3(a,b,c) and (a < -9 and a >-100) and (b < -9 and b >-100) and (c < -9 and
c >-100)
#print(DosDigNeg3(-74,-10,-14))
def TresDigitosNeg(a):
return Negativo(a) and a < -99 and a > -1000
#print(TresDigitosNeg(-8747))
def TresDigitosNeg2(a,b):
return TresDigitosNeg(a) and TresDigitosNeg(b)
#print(TresDigitosNeg2(47,-78))
def TresDigitosNeg3(a,b,c):
return TresDigitosNeg2(a,b) and TresDigitosNeg(c)
#print(TresDigitosNeg3(-784,-514,-10))
def UnDigito(a):
return (a>-10 and a<10) and a!=0
#print(UnDigito(2))
def UnDigito2(a,b):
return UnDigito(a) and UnDigito(b)
#print(UnDigito2(-7,40))
def UnDigito3(a,b,c):
return UnDigito2(a,b) and UnDigito(c)
#print(UnDigito3(8,7,-1))
def DosDigitos(a):
return a >-100 and a < 100
#print(DosDigitos(-84))
def DosDigitos2(a,b):
return DosDigitos(a) and DosDigitos(b)
#print(DosDigitos2(7,-444))
def DosDigitos3(a,b,c):
return DosDigitos2(a,b) and DosDigitos(c)
#print(DosDigitos3(71,14,45))
def TresDigitos(a):
return a> -1000 and a < 1000
#print(TresDigitos(-54))
def TresDigitos2(a,b):
return TresDigitos(a) and TresDigitos(b)
#print(TresDigitos2(784,-8475))
def TresDigitos3(a,b,c):
return TresDigitos2(a,b) and TresDigitos(c)
#print(TresDigitos3(847,154,121))
LENGUAJE JAVA
Llamados de las funciones
public static void main(String[] args) {
System.out.println("1.-El numero es par : "+par(222));
System.out.println("1.-El numero es impar : "+impar(57));
System.out.println("2.- Dos numeros son pares : "+dosPares2(4,2));
System.out.println("3.- Dos numeros son pares : "+dosPares3(1,2,2));
System.out.println("4.- Dos numeros son pares : "+dosPares4(4,3,2,1));
System.out.println("5.- Dos numeros son pares : "+dosPares5(1,3,-5,4,-2));
System.out.println("3.- Tres numeros son pares : "+tresPares3(10,4,-2));
System.out.println("4.- Tres numeros son pares : "+tresPares4(10,4,-2,1));
System.out.println("5.- Tres numeros son pares : "+tresPares5(10,4,-2,2,5));
System.out.println("2.- Existe al menos un par : "+existePar2(-1,-3));
System.out.println("3.- Existe al menos un par : "+existePar3(-1,-3,0));
System.out.println("4.- Existe al menos un par : "+existePar4(-1,-3,5,2));
System.out.println("5.- Existe al menos un par : "+existePar5(-1,-3,8,7,0));
System.out.println("2.- Existe al menos un impar : "+existeImpar2(-1,-3));
System.out.println("3.- Existe al menos un impar : "+existeImpar3(-1,-3,0));
System.out.println("4.- Existe al menos un impar : "+existeImpar4(-1,-3,5,2));
System.out.println("5.- Existe al menos un impar : "+existeImpar5(-1,-
3,8,7,0));
System.out.println("2.- Todos son pares : "+todosPares2(-1,-3));
System.out.println("3.- todos son pares : "+todosPares3(-1,-3,0));
System.out.println("4.- Todos son pares: "+todosPares4(-1,-3,5,2));
System.out.println("5.- Todos son pares: "+todosPares5(-1,-3,8,7,0));
System.out.println("2.- Todos son impares : "+todosImpares2(-1,-3));
System.out.println("3.- Todos son impares : "+todosImpares3(-1,-3,0));
System.out.println("4.- Todos osn impares : "+todosImpares4(-1,-3,5,2));
System.out.println("5.- Todos son impares : "+todosImpares5(-1,-3,8,7,0));
System.out.println("2.- Hay un par y imoar : "+parImpar2(1,-2));
System.out.println("3.- Hay un par y impar : "+parImpar3(-2,-1,-3));
System.out.println("4.- Hay un par y impar : "+parImpar4(1,4,0,0));
System.out.println("5.- Hay un par y impar : "+parImpar5(1,1,0,0,5));
System.out.println("2.- Los numeros estan alternados : "+alterno2(2,2));
System.out.println("3.- Los numeros estam alternados : "+alterno3(-2,-1,-3));
System.out.println("4.- Los numeros estam alternados : "+alterno4(-2,-1,-
6,9));
System.out.println("5.- Los numeros estam alternados : "+alterno5(-2,5,9,-1,-
3));
System.out.println("2.- Todos los numeros son iguales : "+iguales2(-2,2));
System.out.println("3.- Todos los numeros son iguales : "+iguales3(-2,-1,-3));
System.out.println("4.- Todos los numeros son iguales : "+iguales4(-2,-1,-
6,9));
System.out.println("5.- Todos los numeros son iguales :
"+iguales5(0,0,0,0,0));
System.out.println("2.- Todos los numeros son diferentes :
"+diferentes2(2,2));
System.out.println("3.- Todos los numeros son diferentes : "+diferentes3(-2,-
1,-3));
System.out.println("4.- Todos los numeros son diferentes : "+diferentes4(-2,-
1,-6,9));
System.out.println("5.- Todos los numeros son diferentes :
"+diferentes5(0,0,0,0,0));
System.out.println("2.- Dos nnumeros son iguales : "+dosIguales2(2,2));
System.out.println("3.- Dos nnumeros son iguales : "+dosIguales3(-2,-1,-3));
System.out.println("4.- Dos nnumeros son iguales : "+dosIguales4(-2,12,2,2));
System.out.println("5.- Dos nnumeros son iguales : "+dosIguales5(2,2,1,9,0));
System.out.println("3.- Tres nnumeros son iguales : "+tresIguales3(2,2,2));
System.out.println("4.- Tres nnumeros son iguales : "+tresIguales4(21,2,2,2));
System.out.println("5.- Tres nnumeros son iguales :
"+tresIguales5(21,12,2,2,2));
System.out.println("2.- Esta en orden ascendente o son iguales :
"+secuenciaAsc2(2,2));
System.out.println("3.- Esta en orden ascendente o son iguales :
"+secuenciaAsc3(2,2,2));
System.out.println("4.- Esta en orden ascendente o sos iguales :
"+secuenciaAsc4(21,2,2,2));
System.out.println("5.- Esta en orden ascendente o son iguales :
"+secuenciaAsc5(21,12,2,2,2));
System.out.println("2.- Esta en orden descendente : "+secuenciaDesc2(2,1));
System.out.println("3.- Esta en orden descendente : "+secuenciaDesc3(7,5,2));
System.out.println("4.- Esta en orden descendente :
"+secuenciaDesc4(21,2,2,2));
System.out.println("5.- Esta en orden descendente :
"+secuenciaDesc5(21,19,18,6,2));
System.out.println("2.- Es un palindromo : "+palindrome2(2,2));
System.out.println("3.- Es un palindromo : "+palindrome3(1,2,1));
System.out.println("4.- Es un palindromo : "+palindrome4(1,2,2,1));
System.out.println("5.- Es un palindromo : "+palindrome5(1,2,1,2,1));
System.out.println("2.- Es poker : "+poker2(2,1));
System.out.println("3.- Es poker : "+poker3(1,2,1));
System.out.println("4.- Es poker : "+poker4(1,2,2,1));
System.out.println("5.- Es poker : "+poker5(2,2,2,2,1));
System.out.println("2.- Un argumento es sumando de todos los demas :
"+sumandos2(2,1));
System.out.println("3.- Un argumento es sumando de todos los demas :
"+sumandos3(3,2,1));
System.out.println("4.- Un argumento es sumando de todos los demas :
"+sumandos4(3,2,1,0));
System.out.println("5.- Un argumento es sumando de todos los demas :
"+sumandos5(3,2,1,-5,1));
System.out.println("3.- Un argumento es division de otros dos :
"+divisionEntera3(25,5,5));
System.out.println("4.- Un argumento es division de otros dos :
"+divisionEntera4(25,5,5 ,1));
System.out.println("1.- Todos son enteros positivos : "+pos(2));
System.out.println("2.- Todos son enteros positivos : "+pos2(2,1));
System.out.println("3.- Todos son enteros positivos : "+pos3(3,2,1));
System.out.println("1.- Todos son enteros negativos : "+neg(2));
System.out.println("2.- Todos son enteros negativos: "+neg2(2,1));
System.out.println("3.- Todos son enteros negativos : "+neg3(3,2,1));
System.out.println("2.- Son enteros positivo y negativo : "+neg2(2,1));
System.out.println("3.- Son enteros positivo y negativo : "+neg3(3,2,1));
System.out.println("1.-Es un entero positivo de un digito : "+unDigPos(222));
System.out.println("1.-Es un entero negativo de un digito : "+unDigNeg(222));
System.out.println("1.- Son enteros positivos de dos digitos :
"+dosDigPos(2));
System.out.println("2.- Son enteros positivos de dos digitos :
"+dosDigPos2(2,1));
System.out.println("3.- Son enteros positivos de dos digitos :
"+dosDigPos3(3,2,1));
System.out.println("1.- Son enteros negativos de dos digitos :
"+dosDigNeg(2));
System.out.println("2.- Son enteros nesitivos de dos digitos :
"+dosDigNeg2(2,1));
System.out.println("3.- Son enteros nesitivos de dos digitos :
"+dosDigNeg3(3,2,1));
System.out.println("1.- Son enteros negativos de tres digitos : "+tresDigNeg(-
122));
System.out.println("2.- Son enteros nesitivos de tres digitos :
"+tresDigNeg2(-100,-151));
System.out.println("3.- Son enteros nesitivos de tres digitos :
"+tresDigNeg3(3,2,1));
System.out.println("1.- Son enteros de un solo digito positivo o negativo :
"+unDig(-122));
System.out.println("2.- Son enteros de un solo digito positivo o negativo :
"+unDig2(-100,-151));
System.out.println("3.- Son enteros de un solo digito positivo o negativo :
"+unDig3(3,2,1));
System.out.println("1.- Son enteros de dos digitos positivo o negativo :
"+dosDig(-122));
System.out.println("2.- Son enteros de dos digitos positivo o negativo :
"+dosDig2(-100,-151));
System.out.println("3.- Son enteros de dos digitos positivo o negativo :
"+dosDig3(3,2,1));
System.out.println("1.- Son enteros de tres digitos positivo o negativo :
"+tresDig(-122));
System.out.println("2.- Son enteros de tres digitos positivo o negativo :
"+tresDig2(-100,-151));
System.out.println("3.- Son enteros de tres digitos positivo o negativo :
"+tresDig3(3,2,1));
}
//PRACTICO 3
// Función lógica que devuelve True, si a es un número impar.
//par(a)
public static boolean par(int a ){
return a % 2 == 0 && a != 0;
}
//impar(a):
public static boolean impar(int a ){
return !par(a);
}
/*Función lógica que devuelve True,si entre los
argumentos solo dos son pares las otras impares*/
//dosPares(a, b)
public static boolean dosPares2( int a, int b ){
return par(a) && par (b);
}
//dosPares(a, b, c)
public static boolean dosPares3( int a, int b, int c ){
return par(a) && par(b) && impar(c) ||
par(a) && par(c) && impar(b) ||
par(b) && par(c) && impar(a);
}
//dosPares(a, b, c, d)
public static boolean dosPares4( int a, int b, int c, int d ){
return par(a) && par(b) && impar(c) && impar(d) ||
par(a) && par(c) && impar(b) && impar(d) ||
par(a) && par(d) && impar(b) && impar(c) ||
par(b) && par(c) && impar(a) && impar(d) ||
par(b) && par(d) && impar(a) && impar(c) ||
par(c) && par(d) && impar(a) && impar(b);
}
//dosPares(a, b, c, d, e)
public static boolean dosPares5( int a, int b, int c, int d, int e ){
boolean bd = false ;
int cont= 0;
if ( a % 2 == 0 && a != 0 ) cont= cont + 1;
if ( b % 2 == 0 && b != 0 ) cont= cont + 1;
if ( c % 2 == 0 && c != 0 ) cont= cont + 1;
if ( d % 2 == 0 && d != 0 ) cont= cont + 1;
if ( e % 2 == 0 && e != 0 ) cont= cont + 1;
if ( cont == 2 ) bd = true;
return bd;
}
/* Función Lógica que devuelve True, si tres
argumentos son pares y las otras impares.*/
//tresPares(a, b, c)
public static boolean tresPares3( int a, int b, int c){
boolean bd = false ;
int cont= 0;
if ( a % 2 == 0 && a != 0 ) cont= cont + 1;
if ( b % 2 == 0 && b != 0 ) cont= cont + 1;
if ( c % 2 == 0 && c != 0 ) cont= cont + 1;
if ( cont == 3 ) bd = true;
return bd;
}
//tresPares(a, b, c, d)
public static boolean tresPares4( int a, int b, int c, int d ){
boolean bd = false ;
int cont= 0;
if ( a % 2 == 0 && a != 0 ) cont= cont + 1;
if ( b % 2 == 0 && b != 0 ) cont= cont + 1;
if ( c % 2 == 0 && c != 0 ) cont= cont + 1;
if ( d % 2 == 0 && d != 0 ) cont= cont + 1;
if ( cont == 3 ) bd = true;
return bd;
}
//tresPares(a, b, c, d, e
public static boolean tresPares5( int a, int b, int c, int d, int e ){
boolean bd = false ;
int cont= 0;
if ( a % 2 == 0 && a != 0 ) cont= cont + 1;
if ( b % 2 == 0 && b != 0 ) cont= cont + 1;
if ( c % 2 == 0 && c != 0 ) cont= cont + 1;
if ( d % 2 == 0 && d != 0 ) cont= cont + 1;
if ( e % 2 == 0 && e != 0 ) cont= cont + 1;
if ( cont == 3 ) bd = true;
return bd;
}
/*+Función lógica que devuelve True, si de entre todos
los argumentos existe al menos un argumento par.*/
//existePar(a, b)
public static boolean existePar2( int a, int b){
boolean bd = false;
if ( a % 2 == 0 && a != 0 ) bd = true;
if ( b % 2 == 0 && b != 0 ) bd = true;
return bd;
}
//existePar(a, b, c)
public static boolean existePar3( int a, int b, int c ){
boolean bd = false;
if ( a % 2 == 0 && a != 0 ) bd = true;
if ( b % 2 == 0 && b != 0 ) bd = true;
if ( c % 2 == 0 && c != 0 ) bd = true;
return bd;
}
//existePar(a, b, c, d)
public static boolean existePar4( int a, int b, int c, int d ){
boolean bd = false;
if ( a % 2 == 0 && a != 0 ) bd = true;
if ( b % 2 == 0 && b != 0 ) bd = true;
if ( c % 2 == 0 && c != 0 ) bd = true;
if ( d % 2 == 0 && d != 0 ) bd = true;
return bd;
}
//existePar(a, b, c, d, e)
public static boolean existePar5( int a, int b, int c, int d, int e ){
boolean bd = false;
if ( a % 2 == 0 && a != 0 ) bd = true;
if ( b % 2 == 0 && b != 0 ) bd = true;
if ( c % 2 == 0 && c != 0 ) bd = true;
if ( d % 2 == 0 && d != 0 ) bd = true;
if ( e % 2 == 0 && e != 0 ) bd = true;
return bd;
}
/*Función lógica que devuelve True, si de entre
todos los argumentos existe al menos un argumento impar.*/
//existeImpar(a, b)
public static boolean existeImpar2( int a, int b){
boolean bd = false;
if ( a % 2 == 0) bd = true;
if ( b % 2 == 0) bd = true;
return bd;
}
//existeImpar(a, b, c)
public static boolean existeImpar3( int a, int b, int c ){
boolean bd = false;
if ( a % 2 != 0) bd = true;
if ( b % 2 != 0) bd = true;
if ( c % 2 != 0) bd = true;
return bd;
}
//existeImpar(a, b, c, d)
public static boolean existeImpar4( int a, int b, int c, int d ){
boolean bd = false;
if ( a % 2 != 0) bd = true;
if ( b % 2 != 0) bd = true;
if ( c % 2 != 0) bd = true;
if ( d % 2 != 0) bd = true;
return bd;
}
//existeImpar(a, b, c, d, e)
public static boolean existeImpar5( int a, int b, int c, int d, int e ){
boolean bd = false;
if ( a % 2 != 0) bd = true;
if ( b % 2 != 0) bd = true;
if ( c % 2 != 0) bd = true;
if ( d % 2 != 0) bd = true;
if ( e % 2 != 0) bd = true;
return bd;
}
/*Función lógica que devuelve True,
si todos los argumentos son pares.*/
//todosPares(a, b)
public static boolean todosPares2( int a, int b){
boolean bd = false ;
int cont= 0;
if ( a % 2 == 0 && a != 0 ) cont= cont + 1;
if ( b % 2 == 0 && b != 0 ) cont= cont + 1;
if ( cont == 2 ) bd = true;
return bd;
}
//todosPares(a,b, c)
public static boolean todosPares3( int a, int b, int c){
boolean bd = false ;
int cont= 0;
if ( a % 2 == 0 && a != 0 ) cont= cont + 1;
if ( b % 2 == 0 && b != 0 ) cont= cont + 1;
if ( c % 2 == 0 && c != 0 ) cont= cont + 1;
if ( cont == 3 ) bd = true;
return bd;
}
//todosPares(a, b, c, d)
public static boolean todosPares4( int a, int b, int c, int d){
boolean bd = false ;
int cont= 0;
if ( a % 2 == 0 && a != 0 ) cont= cont + 1;
if ( b % 2 == 0 && b != 0 ) cont= cont + 1;
if ( c % 2 == 0 && c != 0 ) cont= cont + 1;
if ( d % 2 == 0 && d != 0 ) cont= cont + 1;
if ( cont == 4 ) bd = true;
return bd;
}
//todosPares(a, b, c, d, e)
public static boolean todosPares5( int a, int b, int c, int d, int e ){
boolean bd = false ;
int cont= 0;
if ( a % 2 == 0 && a != 0 ) cont= cont + 1;
if ( b % 2 == 0 && b != 0 ) cont= cont + 1;
if ( c % 2 == 0 && c != 0 ) cont= cont + 1;
if ( d % 2 == 0 && d != 0 ) cont= cont + 1;
if ( e % 2 == 0 && e != 0 ) cont= cont + 1;
if ( cont == 5 ) bd = true;
return bd;
}
/*Función lógica que devuelve True,
si todos los argumentos son impares*/
//todosImpares(a, b)
public static boolean todosImpares2( int a, int b){
boolean bd = false ;
int cont= 0;
if ( a % 2 != 0 ) cont= cont + 1;
if ( b % 2 != 0 ) cont= cont + 1;
if ( cont == 2 ) bd = true;
return bd;
}
//todosImpares(a,b, c)
public static boolean todosImpares3( int a, int b, int c){
boolean bd = false ;
int cont= 0;
if ( a % 2 != 0 ) cont= cont + 1;
if ( b % 2 != 0 ) cont= cont + 1;
if ( c % 2 != 0 ) cont= cont + 1;
if ( cont == 3 ) bd = true;
return bd;
}
//todosImpares(a, b, c, d)
public static boolean todosImpares4( int a, int b, int c, int d){
boolean bd = false ;
int cont= 0;
if ( a % 2 != 0 ) cont= cont + 1;
if ( b % 2 != 0 ) cont= cont + 1;
if ( c % 2 != 0 ) cont= cont + 1;
if ( d % 2 != 0 ) cont= cont + 1;
if ( cont == 4 ) bd = true;
return bd;
}
//todosImpares(a, b, c, d, e)
public static boolean todosImpares5( int a, int b, int c, int d, int e ){
boolean bd = false ;
int cont= 0;
if ( a % 2 != 0 ) cont= cont + 1;
if ( b % 2 != 0 ) cont= cont + 1;
if ( c % 2 != 0 ) cont= cont + 1;
if ( d % 2 != 0 ) cont= cont + 1;
if ( e % 2 != 0 ) cont= cont + 1;
if ( cont == 5 ) bd = true;
return bd;
}
/*Función lógica que devuelve True, si existe al menos un par
y al menos un impar de entre sus argumentos de la función*/
//parImpar(a, b)
public static boolean parImpar2(int a, int b){
boolean bd = false ;
if ( a == 0 && b == 0 ) return bd;
if ( a % 2 == 0 && a != 0 && b % 2 != 0) bd = true;
if ( b % 2 == 0 && b != 0 && a % 2 != 0) bd = true;
return bd ;
}
//parImpar(a, b, c)
public static boolean parImpar3(int a, int b ,int c){
boolean bd = false ;
if ( a == 0 && b == 0 && c == 0 ) return bd;
if ( a % 2 == 0 && a != 0 && b % 2 != 0) bd = true;
if ( b % 2 == 0 && b != 0 && a % 2 != 0) bd = true;
if ( c % 2 == 0 && c != 0 && b % 2 != 0) bd = true;
if ( b % 2 == 0 && b != 0 && c % 2 != 0) bd = true;
if ( a % 2 == 0 && a != 0 && c % 2 != 0) bd = true;
if ( c % 2 == 0 && c != 0 && a % 2 != 0) bd = true;
return bd ;
}
//parImpar(a, b, c, d)
public static boolean parImpar4(int a, int b, int c, int d){
boolean bd = false;
int cp,ci;
cp = 0; ci = 0;
if ( a % 2 == 0 && a != 0 ) cp = cp + 1;
else ci = ci +1;
if ( b % 2 == 0 && b != 0 ) cp = cp + 1;
else ci = ci +1;
if ( c % 2 == 0 && c != 0 ) cp = cp + 1;
else ci = ci +1;
if ( d % 2 == 0 && d != 0 ) cp = cp + 1;
else ci = ci +1;
if ( cp >= 1 && ci >= 1) bd = true;
return bd;
}
//parImpar(a, b, c, d, e)
public static boolean parImpar5(int a, int b, int c, int d,int e){
boolean bd = false;
int cp,ci;
cp = 0; ci = 0;
if ( a % 2 == 0 && a != 0 ) cp = cp + 1;
else ci = ci +1;
if ( b % 2 == 0 && b != 0 ) cp = cp + 1;
else ci = ci +1;
if ( c % 2 == 0 && c != 0 ) cp = cp + 1;
else ci = ci +1;
if ( d % 2 == 0 && d != 0 ) cp = cp + 1;
else ci = ci +1;
if ( e % 2 == 0 && e != 0 ) cp = cp + 1;
else ci = ci +1;
if ( cp >= 1 && ci >= 1) bd = true;
return bd;
}
/*Función lógica que devuelve True, si la secuencia
de argumentos se alternande pares e impares. No pueden
haber dos argumentos juntos pares o impares.*/
//alterno(a, b)
public static boolean alterno2( int a, int b){
boolean bd =false;
if ( a % 2 == 0 && a!=0 && b % 2 !=0 ) bd = true;
if ( b % 2 == 0 && b!=0 && a % 2 !=0 ) bd = true;
return bd;
}
//alterno (a, b, c)
public static boolean alterno3( int a, int b, int c){
boolean bd =false;
if ( a % 2 == 0 && a!=0 && b % 2 !=0 && c % 2 == 0 && c != 0) bd = true;
if ( a % 2 != 0 && b % 2 == 0 && b != 0 && c % 2 !=0) bd = true;
return bd;
}
//alterno (a, b, c, d)
public static boolean alterno4( int a, int b, int c, int d){
boolean bd = false;
if ( a%2==0 && a!=0 && b%2!=0 && c%2==0 && c!=0 && d%2!=0) bd = true;
if ( d%2==0 && d!=0 && c%2!=0 && b%2==0 && b!=0 && a%2!=0) bd = true;
return bd;
}
//alterno (a, b, c, d, e)
public static boolean alterno5( int a, int b, int c, int d, int e){
boolean bd = false;
if ( a%2==0 && a!=0 && b%2!=0 && c%2==0 && c!=0 && d%2!=0 && e%2==0 && e!=0)
bd = true;
if ( e%2==0 && e!=0 && d%2!=0 && c%2==0 && c!=0 && b%2!=0 && a%2==0 && a!=0)
bd = true;
return bd;
}
/*Función lógica que devuelve True, si todos
los argumentos son iguales. Sugerencia, expresar en
función de los predicados anteriores.*/
//iguales(a, b)
public static boolean iguales2( int a, int b){
boolean bd = false;
if ( a==b ) bd = true;
return bd;
}
//iguales(a, b, c)
public static boolean iguales3( int a, int b,int c){
boolean bd = false;
if ( a==b && b==c ) bd = true;
return bd;
}
//iguales(a, b, c, d)
public static boolean iguales4( int a, int b,int c,int d){
boolean bd = false;
if ( a==b && b==c && c==d) bd = true;
return bd;
}
//iguales(a, b, c, d, e)
public static boolean iguales5( int a, int b,int c,int d,int e){
boolean bd = false;
if ( a==b && b==c && c==d && d==e) bd = true;
return bd;
}
/*Función lógica que devuelve True, si
todos los argumentos son diferentes.*/
//direntes(a, b)
public static boolean diferentes2(int a,int b){
boolean bd = false;
if ( a!=b ) bd = true;
return bd;
}
//diferentes(a, b, c)
public static boolean diferentes3(int a,int b, int c){
boolean bd = false;
if ( a!=b && b!=c ) bd = true;
return bd;
}
//diferentes(a, b, c, d)
public static boolean diferentes4(int a,int b, int c, int d){
boolean bd = false;
if ( a!=b && b!=c && c!=d ) bd = true;
return bd;
}
//diferentes(a, b, c, d, e)
public static boolean diferentes5(int a,int b, int c, int d, int e){
boolean bd = false;
if ( a!=b && b!=c && c!=d && d!=e ) bd = true;
return bd;
}
/*Función lógica que devuelve True, si existen
dos argumentos iguales y los otros argumentos diferentes
entre ellos y diferentes a los dos iguales.*/
//dosIguales(a, b)
public static boolean dosIguales2( int a, int b){
boolean bd = false;
if ( a==b ) bd = true;
return bd;
}
//dosIguales(a, b, c)
public static boolean dosIguales3(int a, int b, int c ){
boolean bd = false;
if ( a==b && c!=b ) bd=true;
if ( a==c && b!=a ) bd=true;
if ( b==c && a!=b ) bd=true;
return bd;
}
///dosIguales(a, b, c, d)
public static boolean dosIguales4(int a, int b, int c, int d ){
boolean bd = false;
if ( a==b && c!=b && d!=b ) bd=true;
if ( a==c && b!=a && d!=a ) bd=true;
if ( b==c && a!=b && d!=b ) bd=true;
if ( a==d && b!=a && c!=a ) bd=true;
if ( b==d && c!=b && a!=b ) bd=true;
if ( d==c && a!=d && b!=d ) bd=true;
return bd;
}
//dosIguales(a, b, c, d, e)
public static boolean dosIguales5(int a, int b, int c, int d, int e ){
boolean bd = false;
if ( a==b && c!=b && d!=b && e!=b) bd=true;
if ( a==c && b!=a && d!=a && e!=a) bd=true;
if ( b==c && a!=b && d!=b && e!=b) bd=true;
if ( a==d && b!=a && c!=a && e!=a) bd=true;
if ( b==d && c!=b && a!=b && e!=b) bd=true;
if ( d==c && a!=d && b!=d && e!=d) bd=true;
if ( a==e && b!=a && c!=a && d!=a) bd=true;
if ( b==e && a!=e && c!=e && d!=e) bd=true;
if ( c==e && a!=e && b!=e && d!=e) bd=true;
if ( d==e && a!=d && b!=d && c!=d) bd=true;
return bd;
}
/*Función lógica que devuelve True, si existen
tres argumentos iguales y los otros argumentos diferentes
entre ellos y diferentes a los tres iguales.*/
//tresIguales(a, b, c)
public static boolean tresIguales3(int a, int b, int c ){
boolean bd = false;
if ( a==b && c==b ) bd=true;
if ( a==c && b==a ) bd=true;
if ( b==c && a==b ) bd=true;
return bd;
}
//tresIguales(a, b, c, d)
public static boolean tresIguales4(int a, int b, int c, int d ){
boolean bd = false;
if ( a==b && c==b && d!=b ) bd=true;
if ( b==c && c==d && a!=b ) bd=true;
if ( a==c && c==d && b!=a ) bd=true;
if ( a==b && d==a && c!=a ) bd=true;
return bd;
}
//tresIguales(a, b, c, d, e)
public static boolean tresIguales5(int a, int b, int c, int d, int e ){
boolean bd = false;
if ( a==b && c==b && d!=b && e!=b) bd=true;
if ( b==c && c==d && a!=b && e!=b) bd=true;
if ( a==c && c==d && b!=a && e!=a) bd=true;
if ( a==b && d==a && c!=a && e!=a) bd=true;
if ( a==e && b==a && c!=a && d!=a) bd=true;
if ( b==e && c==a && a!=b && d!=b) bd=true;
if ( c==d && d==e && a!=d && b!=d) bd=true;
if ( a==c && c==e && b!=a && d!=a) bd=true;
if ( a==d && d==e && b!=a && c!=a) bd=true;
return bd;
}
/* Función lógica que devuelve True, si la secuencia
de argumentos es ascendente o iguales. */
//secuenciaAsc(a, b)
public static boolean secuenciaAsc2(int a, int b){
return a<b || iguales2(a,b);
}
//secuenciaAsc(a, b, c)
public static boolean secuenciaAsc3(int a,int b, int c ){
return a<b && b<c || iguales3(a,b,c);
}
//secuenciaAsc(a, b, c, d)
public static boolean secuenciaAsc4(int a,int b, int c,int d ){
return a<b && b<c && c<d || iguales4(a,b,c,d);
}
//secuenciaAsc(a, b, c, d, e)
public static boolean secuenciaAsc5(int a,int b, int c,int d, int e){
return a<b && b<c && c<d && d<e || iguales5(a,b,c,d,e);
}
/*Función lógica que devuelve True, si la
secuencia de argumentos es decreciente o iguales.*/
//secuenciaDesc(a, b)
public static boolean secuenciaDesc2(int a, int b){
return a>b || iguales2(a,b);
}
//secuenciaDesc(a, b, c)
public static boolean secuenciaDesc3(int a,int b, int c ){
return a>b && b>c || iguales3(a,b,c);
}
//secuenciaDesc(a, b, c, d)
public static boolean secuenciaDesc4(int a,int b, int c,int d ){
return a>b && b>c && c>d || iguales4(a,b,c,d);
}
//secuenciaDesc(a, b, c, d, e)
public static boolean secuenciaDesc5(int a,int b, int c,int d, int e){
return a>b && b>c && c>d && d>e || iguales5(a,b,c,d,e) ;
}
/* Función lógica que devuelve True, si la secuencia deargumentos
es la misma en ambos sentidos, es decir se secuencia de izquierda a
derechaes la misma que la secuencia de derecha a izquierda. */
//palindrome(a, b)
public static boolean palindrome2(int a, int b){
boolean bd = false;
if ( a==b ) bd = true;
return bd;
}
//palindrome(a, b, c)
public static boolean palindrome3(int a, int b, int c){
return a == c ;
}
//palindrome(a, b, c, d)
public static boolean palindrome4(int a, int b, int c, int d){
return a == d && b == c ;
}
//palindrome(a, b, c, d, e)
public static boolean palindrome5(int a, int b, int c, int d,int e){
return a == e && b == d ;
}
/*Función Lógica que devuelve True,
si los argumentos de la función forman poker.
(Todos son iguales excepto uno)*/
//poker(a, b)
public static boolean poker2(int a, int b){
return a != b;
}
//poker(a, b, c)
public static boolean poker3(int a, int b, int c){
return a == b && c != a || b == c && a != c || c == a && b != a;
}
//poker(a, b, c, d)
public static boolean poker4(int a, int b, int c ,int d){
return iguales3(a,b,c) && d != a || iguales3(a,c,d) && b != a ||
iguales3(b,c,d) && a != b || iguales3(a,b,d) && c !=a;
}
//poker(a, b, c, d, e)
public static boolean poker5(int a, int b, int c ,int d, int e){
return iguales4(a,b,c,d) && e != a || iguales4(a,b,c,e) && d != a
|| iguales4(a,b,d,e) && c != a || iguales4(a,c,d,e)
&& b != a || iguales4(b,c,d,e) && a != b;
}
/*Función lógica que devuelve True, un argumento
es igual a la suma de todos los otros argumentos.*/
//sumandos(a, b)
public static boolean sumandos2(int a, int b){
return iguales2(a,b);
}
//sumandos(a, b, c)
public static boolean sumandos3(int a, int b, int c){
return a == b + c || b == a + c || c == a + b;
}
//sumandos(a, b, c, d)
public static boolean sumandos4(int a, int b, int c, int d){
return a == b + c + d || b == a + c +d || c == a + b + d
|| d == a + b + c;
}
//sumandos(a, b, c, d, e)
public static boolean sumandos5(int a, int b, int c, int d, int e){
return a == b + c + d + e || b == a + c +d + e || c == a + b + d + e
|| d == a + b + c + e || e == a + b + c + d ;
}
/*Función lógica que devuelve True, si entre los argumentos
existe un argumento que es igual a la división entera de otros
dos argumentos.*/
//divisionEntera(a, b, c)
public static boolean divisionEntera3(int a, int b, int c){
return a == b/c || a == c/b || b == a/c || b == c/a || c == a/b
|| c == b/a;
}
//divisionEntera(a, b, c, d)
public static boolean divisionEntera4(int a, int b, int c, int d){
return a == b/c || a == c/b || a == b/d || a == d/b || a == c/d
|| a == d/c || b == a/c || b == c/a || b == a/d || b == d/a
|| b == c/d || b == d/c || c == a/b || c == b/a || c == a/d
|| c == d/a || c == b/d || c == d/b;
}
/*_Función Lógica que devuelve True, todos los
argumentos de la función son enteros positivos.*/
//positivo(a)
public static boolean pos(int a){
return a > 0;
}
//positivo(a, b)
public static boolean pos2(int a, int b){
return pos(a) && pos(b);
}
//positivo(a, b, c)
public static boolean pos3(int a, int b, int c){
return pos(a) && pos(b) && pos(c);
}
/*Función Lógica que devuelve True, si todos los argumentos
de la función son enteros negativos.*/
//negativo(a)
public static boolean neg( int a){
return a < 0;
}
//negativo(a, b)
public static boolean neg2( int a, int b){
return a < 0 && b < 0;
}
//negativo(a, b, c)
public static boolean neg3( int a, int b, int c){
return a < 0 && b < 0 && c < 0;
}
/* Función Lógica que devuelve True, si entre todos los argumentos
existen argumentos positivos y argumentos negativo*/
//postivoNeg(a, b),
public static boolean posNeg2(int a, int b){
return pos(a) && neg(b);
}
//positivoNeg(a, b, c)
public static boolean posNeg3(int a, int b, int c){
return pos3(a,b,c) || neg3(a,b,c);
}
/*Función Lógica que devuelve True, si el entero n, es un entero positivo de un
solo
dígito. Si el entero n, tiene más de dos dígitos devuelve false.*/
//unDigitoPos( n )
public static boolean unDigPos(int n){
return n > 0 && n < 10;
}
/*Función Lógica que devuelve True,si el entero n,
es un entero negativo de un solo dígito.*/
//unDigitoNeg( n )
public static boolean unDigNeg(int n){
return n < 0 && n > -10;
}
/*Función Lógica que devuelve True, si todos los argumentos
son enteros positivos de dos dígitos.*/
//dosDigitosPos(a)
public static boolean dosDigPos(int a){
return a >= 10;
}
//dosDigitosPos(a, b)
public static boolean dosDigPos2(int a, int b){
return a >= 10 && b >= 10;
}
//dosDigitosPos(a, b, c)
public static boolean dosDigPos3(int a, int b, int c){
return a >= 10 && b >=10 && c >= 10;
}
/*Función Lógica que devuelve True, si todos
los argumentos son enteros negativos de dos dígitos.*/
//dosDigitosNeg(a)
public static boolean dosDigNeg(int a){
return a <= -10;
}
//dosDigitosNeg(a, b)
public static boolean dosDigNeg2(int a, int b){
return a <= -10 && b <= -10;
}
//dosDigitosNeg(a, b, c)
public static boolean dosDigNeg3(int a, int b, int c){
return a <= 10 && b <=10 && c <= 10;
}
/*Función Lógica que devuelve True, si todos los argumentos
son enteros negativos de tres dígitos.*/
//tresDigitosNeg(a)
public static boolean tresDigNeg(int a){
return a <= -100;
}
//tresDigitosNeg(a, b)
public static boolean tresDigNeg2(int a, int b){
return a <= -100 && b <= -100;
}
//tresDigitosNeg(a, b, c)
public static boolean tresDigNeg3(int a, int b, int c){
return a <= -100 && b <= -100 && c <= -100;
}
/*Función Lógica que devuelve True, si todos los argumentos de
la función son enteros de un solo dígito y pueden ser positivos
y/o negativos.*/
//unDigito(a)
public static boolean unDig(int a){
return a > -10 && a < 0 || a > 0 && a < 10;
}
//unDigito(a, b)
public static boolean unDig2(int a,int b){
return unDig(a) && unDig(b);
}
//unDigito(a, b, c)
public static boolean unDig3(int a,int b, int c){
return unDig(a) && unDig(b) && unDig(c);
}
/*Función Lógica que devuelve True, si todos los argumentos
de la función son enteros de dos dígito y pueden ser positivos
y/o negativos.*/
//dosDigitos(a)
public static boolean dosDig(int a){
return a < -10 && a > -100 || a > 10 && a < 100;
}
//dosDígitos(a, b)
public static boolean dosDig2(int a,int b){
return dosDig(a) && dosDig(b);
}
//dosDígitos(a, b, c)
public static boolean dosDig3(int a,int b, int c){
return dosDig(a) && dosDig(b) && unDig(c);
}
/*Función Lógica que devuelve True, si todos los argumentos de la función
son enteros de tres dígitos y pueden ser positivos y/o negativos.*/
//tresDígitos(a)
public static boolean tresDig(int a){
return a < -99 && a > -1000 || a > 99 && a < 1000;
}
//tresDígitos(a, b)
public static boolean tresDig2(int a, int b){
return tresDig(a) && tresDig(b);
}
//tresDigitos(a, b, c)
public static boolean tresDig3(int a, int b, int c){
return tresDig(a) && tresDig(b) && tresDig(c);
}
}
COMENTARIO: En este práctico tuvimos algunas dificultades en algunas partes en
especial en la de 3 iguales ya que no conocíamos bien este tema de las 2 iguales en 5
variables y en 3 iguales en 5 variables, palíndromo y póker, la forma de llamar al
boolean, ya que en Python lo reconoce automáticamente mientras que en Java hay que
designar el tipo de boolean, pero aun así pudimos resolverlo, este tema nos ayudó a
mejorar un poco como grupo ya que nos ayudamos mutuamente e individualmente a
mejorar, ya que algunos tuvieron algunas dudas y los demás ayudaron. No pudimos
reunirnos tanto en este práctico de manera grupal así que la lógica varía en realizar
el práctico.