Created
December 8, 2018 03:11
-
-
Save joaquinmartinezrod/e09c1fd0a784a3b098f32b5a0a5bc473 to your computer and use it in GitHub Desktop.
Determina si una frase es Palindroma o no
#palindrome #palindroma #palindromo #java
Para la clase de Estructura de Datos ITCelaya
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Algoritmos.Examen1; | |
public class FrasePalindroma { | |
boolean palindromo; | |
public FrasePalindroma(){ | |
palindromo = false; | |
} | |
public void setPalindromo(boolean bool){ | |
palindromo = bool; | |
} | |
public void esPalindromo(String frase){ | |
frase=frase.replace(" ", ""); | |
frase=frase.replace(",", ""); | |
frase=frase.replace(".", ""); | |
int tam = frase.length()-1; | |
int i = 0; | |
setPalindromo(true); | |
while(i < tam){ | |
if(frase.charAt(i)!=frase.charAt(tam)) | |
setPalindromo(false); | |
i++; | |
tam--; | |
} | |
} | |
public boolean getPalindromo(){ | |
return palindromo; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment