beingtopper.jkp@gmail.com
+91-8700702530
Free Demo

Being Topper

  • About Us
  • Knowledge Base
  • Modules
  • Branches
    • Ajmer
    • Tilak Nagar
    • Noida
    • Chandigarh
    • Mumbai
  • Contact Us

Being Topper

  • About Us
  • Knowledge Base
  • Modules
  • Branches
    • Ajmer
    • Tilak Nagar
    • Noida
    • Chandigarh
    • Mumbai
  • Contact Us
  • About Us
  • Knowledge Base
  • Modules
  • Branches
    • Ajmer
    • Tilak Nagar
    • Noida
    • Chandigarh
    • Mumbai
  • Contact Us

Being Topper

  • About Us
  • Knowledge Base
  • Modules
  • Branches
    • Ajmer
    • Tilak Nagar
    • Noida
    • Chandigarh
    • Mumbai
  • Contact Us
B.tech notesBCA NOTESEvent HandlingInformation technologyJava ProgramsPrograms/Algorithm

java program for counting vowels , consonants , digits and whitespaces …

Being Topper 17/03/2014 0 Comments

Java program for counting vowels , consonants , digits and white spaces

//this program is for counting vowels , consonants , digits and whitespaces ....
import java.awt.*;
import java.awt.event.*;
class EventTest implements ActionListener
{ Frame fr;
Button b1;
TextField tf1,tf2,tf3,tf4,tf5;
EventTest( )
{ fr = new Frame("myframe" );
fr.setLayout(null);
b1= new Button ("Calc") ;
tf1 = new TextField() ;
tf2 = new TextField() ;
tf3= new TextField() ;
tf4 = new TextField () ;
tf5 = new TextField () ;

tf1.setBounds( 50,50,100,50) ;
b1.setBounds( 50,120,50,50);

tf2.setBounds( 50,190,100,50) ;
tf3.setBounds( 50,260,100,50) ;
tf4.setBounds( 50,330,100,50) ;
tf5.setBounds( 50,400,100,50) ;

fr.add( tf1) ;
fr.add( tf2) ;
fr.add( tf3) ;
fr.add(tf4) ;
fr.add(tf5) ;
fr.add( b1) ;

b1.addActionListener( this );
fr.setSize(600,700);
fr.setVisible(true);
}
public void actionPerformed (ActionEvent e )
{
if ( e.getSource() == b1 )
{
String str1 = tf1.getText() ;
char ch[] = str1.toCharArray() ;
int j= ch.length; int dcount = 0 ;int dconsonant =0;int dvowel =0; int dspace = 0;
for ( int i = 0 ; i<j; i++ )
{
if ( ch[i] == '1'| ch[i]== '2' | ch[i]== '3'| ch[i]== '4'| ch[i]=='5'|ch[i]=='6'|ch[i]=='7'| ch[i]=='8'|ch[i]=='9'|ch[i]=='0')
dcount++;

else if ( ch[i] == ' ' )
dspace++ ;
else {
for (char c = 65 ; c<123 ;c++ )
{
if (c>90&c<97)
{
continue ;
}

else if ( c==65|c==97|c==69|c==73|c==79|c==85|c==101|c==105|c== 111|c==117 & ch[i]==c)
{ if (ch[i]== c){
dvowel++ ;
break; }
}

else
{
if (ch[i] == c)
{ dconsonant++;
break;
}
}

}

}

}
tf2.setText (" " + dcount);
tf3.setText( ""+dvowel );
tf4.setText( ""+dconsonant);
tf5.setText(""+dspace);
}
}
public static void main (String s[] )
{
new EventTest();
}

}
java programs
AboutBeing Topper
In Socials:
PrevJava program for event Handelling17/03/2014
Java program on Deadlock17/03/2014Next
Categories
Recent Posts
  • Best Email Marketing Software and Services
  • How to Apply Adsense on YouTube
  • Complete Guide to Writing a Newsletter !
  • Benefits of Creating Email List for small Businesses | Digital Marketing
  • Create Account or Get Email Alerts When New Employees Join a Company

Copyright © 2021 Being Topper ® . All Rights Reserved