public class VowelsAndConsonants extends JApplet {
JTextArea Xout = new JTextArea(20, 50);
public void init() {
Container cp = getContentPane();
cp.setLayout(new FlowLayout());
cp.add(new JLabel("VowelsAndConsonants!"));
cp.add(new JScrollPane(Xout));
for(int i = 0; i < 100; i++) {
char c = (char)(Math.random() * 26 + 'a');
Xout.append(" " + c + ": ");
switch(c) {
case 'a':
case 'e':
case 'i':
case 'o':
case 'u':
Xout.append("vowel\n");
break;
case 'y':
case 'w':
Xout.append(
"Sometimes a vowel\n");
break;
default:
Xout.append("consonant\n");
}
}
}
public static void main(String[] args) {
Console.run(new VowelsAndConsonants (), 600, 400);
}
} ///:~