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));
}

}

}









Comments

Popular posts from this blog

Write a java program to create an abstract class named Shape that contains two integers and an abstract method named printArea(). Provide three classes named Rectangle, Triangle and Circle such that each one of the classes extends the class Shape. Each one of the classes contain only the method printArea( ) that prints the area of the given shape.

Create Employee Class with Method getdata and setdata. Create following subclasses to generate biodata. i) Personal record ii)) Professional record iii) Academic record Assume appropriate data members and member function to accept required data & print bio-data. Use Overriding at suitable places.Create bio-data using multilevel inheritances.

Exception_Handling Program