Palindrome en Java Swing
 
Palindrome en Java Swing
 
Clase Java que calcula si una palabra es palindorme o no, funciona con elementos de la libreria 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;
    }
    }
    }
    }
}
 
Regresar al Inicio