VOWELS
/*
<applet code=vowels width=300 height=300>
</applet>
*/
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class vowels extends Applet implements ActionListener
{
TextField disp;
TextArea area;
Button chk;
public void init()
{
chk=new Button(" CHECK ");
area=new TextArea(10,20);
disp=new TextField(15);
add(area);
add(disp);
add(chk);
chk.addActionListener(this);
}
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==chk)
{
String s=new String();
s=area.getText();
int cnt=0;
char ch;
for(int i=0;i<s.length();i++)
{
ch=s.charAt(i);
if(ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u'||ch=='A'||ch=='E'||ch=='I'||ch=='O'||ch=='U')
{
cnt++;
}
}
disp.setText(Integer.toString(cnt));
}
}
}
<applet code=vowels width=300 height=300>
</applet>
*/
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class vowels extends Applet implements ActionListener
{
TextField disp;
TextArea area;
Button chk;
public void init()
{
chk=new Button(" CHECK ");
area=new TextArea(10,20);
disp=new TextField(15);
add(area);
add(disp);
add(chk);
chk.addActionListener(this);
}
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==chk)
{
String s=new String();
s=area.getText();
int cnt=0;
char ch;
for(int i=0;i<s.length();i++)
{
ch=s.charAt(i);
if(ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u'||ch=='A'||ch=='E'||ch=='I'||ch=='O'||ch=='U')
{
cnt++;
}
}
disp.setText(Integer.toString(cnt));
}
}
}
Comments
Post a Comment