Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Palindrome en Java

Palindrome es una Palabra que se lee igual de izquierda a derecha  o derecha a izquierda, un ejemplo puede ser la frase “ana lava lana”. Vamos a realizar un programa en Java que permita saber si una palabra es Palindrome o no, funciona con elementos de la librería Swing de Java.

import javax.swing.* ;
public class palindrome{
public static void main ( String args[] ) {
String q,w,r;
 int wer1;
wer1 = 0;
 while (0==0) {
 q = JOptionPane.showInputDialog (null, "*1* Palíndrome\n**2**Salir",
 "MENU PRINCIPAL",JOptionPane.PLAIN_MESSAGE);
if (q.equals("1")==false && q.equals("2")==false){
 JOptionPane.showMessageDialog (null, "DIGITE UNA OPCION DEL MENU"," FALTA",JOptionPane.PLAIN_MESSAGE);
 }
 else {
 wer1 = Integer.parseInt(q);
 switch (wer1) {
 case 1:
 q= JOptionPane.showInputDialog (null, "ESCRIBA SU PALABRA","PALABRA",JOptionPane.PLAIN_MESSAGE);
 w = q.substring(0,1);
 r = q.substring(q.length()- 1,q.length());
 if (q.endsWith(w)) {
 JOptionPane.showMessageDialog (null, "LA PALABRA ES PALINDROME","PALINDROME",JOptionPane.PLAIN_MESSAGE);
 }
 else {
 JOptionPane.showMessageDialog (null, " NO ES PALINDROME "," PALINDROME",JOptionPane.PLAIN_MESSAGE);
 }
 break;
 case 2:
 System.exit(0);
 break;
 }
 }
 }
 }
}


This post first appeared on Best Way To Earn Money Online, please read the originial post: here

Share the post

Palindrome en Java

×

Subscribe to Best Way To Earn Money Online

Get updates delivered right to your inbox!

Thank you for your subscription

×