1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
| import java.lang.String;
import javax.swing.JOptionPane ;
public class exo1
{
public class pile
{
private static final int taille=15;
protected char[] tab;
protected int p;
public pile(int t)
{
tab = new char[t];
}
public void raz()
{ p=0;
}
public void empiler(char c)
{
tab[p++]=c;
}
public char depiler()
{
return tab[--p];
}
public int vide()
{ if (p==0)
return 1;
}
public int plein()
{
if (p==14)
return 1;
}
}
public static boolean voyelle(char k)
{ return((k=='a') ||
(k=='o') ||
(k=='i') ||
(k=='e') ||
(k=='y') ||
(k=='u'));
}
public static void main(String args[])
{
pile p;
p=new pile(10);
String laphrase="taper votre phrase";
Static String msg=JOptionPane.showInputDialog(laphrase);
int i;
for(i=0;i<msg.length;i++)
{ if (p.plein()==0)
{ if (voyelle(msg.substring(i,i+1))==true)
{ p.empiler(msg.substring(i,i+1));
JOptionPane.showMessageDialog(null,msg.substring(i,i+1));
}
}
}
}
} |