need help...

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jan 2006
Posts: 7
Reputation: dammika is an unknown quantity at this point 
Solved Threads: 0
dammika dammika is offline Offline
Newbie Poster

need help...

 
0
  #1
Jan 19th, 2006
:cry: ..i hav 2 hand over my java project soon..but i cannot figure out how 2 count da vowels in text i type inside ma textfield...i need a simple method because i just started java..i will be pleased if some one can send me commands for counting vowels in a text..
thank you
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 2,108
Reputation: server_crash is on a distinguished road 
Solved Threads: 18
server_crash server_crash is offline Offline
Postaholic

Re: need help...

 
0
  #2
Jan 19th, 2006
First, you need to clean up your own english(the abbreviations ) so we can understand you. Then you need to show us what you've already done, and specifically what you're having trouble with.

In the meantime, remember Java has a String class with many methods such as indexOf() and other stuff.
Reply With Quote Quick reply to this message  
Join Date: Jan 2006
Posts: 7
Reputation: dammika is an unknown quantity at this point 
Solved Threads: 0
dammika dammika is offline Offline
Newbie Poster

Re: need help...

 
0
  #3
Jan 19th, 2006
this is what i did........

/**
* @(#)VowelAnalyzer.java
*
* Sample Applet application
*
* @author
* @version 1.00 06/01/13
*/

import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class VowelAnalyzer extends Applet implements ActionListener,AdjustmentListener {
Label L1,L2,L3,L4,L5,L6,L7;
Button B1;
Panel p=new Panel();
Panel p1=new Panel();
Panel p2=new Panel();
Panel p3=new Panel();
Panel p4=new Panel();
TextField T1;
int R=0,G=0,B=0,size;
Scrollbar S1,S2,S3;
String word="";
int aCount = 0,eCount = 0,iCount = 0,oCount = 0,uCount = 0;

public void init() {
L1=new Label(" INPUT TEXT:");
L3=new Label(" ");
L4=new Label(" ");
L2=new Label(" COLOR OF VOWELS:");
L5=new Label(" Red");
L6=new Label(" Green");
L7=new Label(" Blue");
T1=new TextField(30);
B1=new Button("Submit");
B1.addActionListener (this);
S1=new Scrollbar(Scrollbar.HORIZONTAL,0,1,0,256);
add(S1);
S1.addAdjustmentListener(this);
S2=new Scrollbar(Scrollbar.HORIZONTAL,0,1,0,256);
add(S2);
S2.addAdjustmentListener(this);
S3=new Scrollbar(Scrollbar.HORIZONTAL,0,1,0,256);
add(S3);
S3.addAdjustmentListener(this);
p.setLayout(new BorderLayout());
p.add("East",L4);
p.add("Center",L1);
p.add("West",L3);
p.add("South",T1);
add(p);
p1.setLayout(new BorderLayout());
p1.add("North",p);
p1.add("South",L2);
add(p1);
p2.setLayout(new GridLayout(2,3,5,1));
p2.add(L5);
p2.add(L6);
p2.add(L7);
p2.add(S1);
p2.add(S2);
p2.add(S3);
add(p2);
p3.setLayout(new BorderLayout());
p3.add("North",p1);
p3.add("South",p2);
add(p3);
p4.setLayout(new BorderLayout(0,2));
p4.add("North",p3);
p4.add("South",B1);
add(p4);
}



public void actionPerformed(ActionEvent e){
word=T1.getText();
repaint();
}

public void adjustmentValueChanged(AdjustmentEvent e){
if(e.getSource()==S1)
R=S1.getValue();
if(e.getSource()==S2)
G=S2.getValue();
if( e.getSource()==S3)
B=S3.getValue();
// setForeground(new Color(R,G,B));
repaint();
}
public void paint(Graphics g) {
g.drawString("Vowels are displayed in RGB color of ("+R+","+G+","+B+").", 10,200);
Font font=new Font("Serif",Font.BOLD,17);
g.setFont(font);
g.setColor(new Color(R,G,B));
g.drawString(""+word, 8, 180 );

}
}

i need some help from here onnnnn.....
Reply With Quote Quick reply to this message  
Join Date: Mar 2004
Posts: 802
Reputation: Phaelax is on a distinguished road 
Solved Threads: 40
Phaelax Phaelax is offline Offline
Practically a Posting Shark

Re: need help...

 
0
  #4
Jan 20th, 2006
next time, use the CODE tags please.

I don't see anything where you tried to solve this yet. But anyway, what you could is store the 5 vowels into an ArrayList. Then loop through each Character in your string and see if it's contained within the array. If it is, then it must be a vowel.
Reply With Quote Quick reply to this message  
Join Date: Jan 2006
Posts: 7
Reputation: dammika is an unknown quantity at this point 
Solved Threads: 0
dammika dammika is offline Offline
Newbie Poster

Re: need help...

 
0
  #5
Jan 23rd, 2006
hey i do da vowel counting....now i need to change ma colors of vowels when i change ma scrollbar..can any 1 help me....
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,273
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 378
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

Re: need help...

 
0
  #6
Jan 23rd, 2006
Originally Posted by dammika
hey i do da vowel counting....now i need to change ma colors of vowels when i change ma scrollbar..can any 1 help me....
Show us ur new code and highlite da areas where is a problem.
*Voted best profile in the world*
Reply With Quote Quick reply to this message  
Join Date: Jan 2006
Posts: 7
Reputation: dammika is an unknown quantity at this point 
Solved Threads: 0
dammika dammika is offline Offline
Newbie Poster

Re: need help...

 
0
  #7
Jan 23rd, 2006
/**
* @(#)VowelAnalyzer.java
*
* Sample Applet application
*
* @author
* @version 1.00 06/01/13
*/

import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class VowelAnalyzer extends Applet implements ActionListener,AdjustmentListener {
Label L1,L2,L3,L4,L5,L6,L7;
Button B1;
Panel p=new Panel();
Panel p1=new Panel();
Panel p2=new Panel();
Panel p3=new Panel();
Panel p4=new Panel();
TextField T1;
int R=0,G=0,B=0,size;
Scrollbar S1,S2,S3;
String word="";

public void init() {
L1=new Label(" INPUT TEXT:");
L3=new Label(" ");
L4=new Label(" ");
L2=new Label(" COLOR OF VOWELS:");
L5=new Label(" Red");
L6=new Label(" Green");
L7=new Label(" Blue");
T1=new TextField(30);
B1=new Button("Submit");
B1.addActionListener (this);
S1=new Scrollbar(Scrollbar.HORIZONTAL,0,1,0,256);
add(S1);
S1.addAdjustmentListener(this);
S2=new Scrollbar(Scrollbar.HORIZONTAL,0,1,0,256);
add(S2);
S2.addAdjustmentListener(this);
S3=new Scrollbar(Scrollbar.HORIZONTAL,0,1,0,256);
add(S3);
S3.addAdjustmentListener(this);
p.setLayout(new BorderLayout());
p.add("East",L4);
p.add("Center",L1);
p.add("West",L3);
p.add("South",T1);
add(p);
p1.setLayout(new BorderLayout());
p1.add("North",p);
p1.add("South",L2);
add(p1);
p2.setLayout(new GridLayout(2,3,5,1));
p2.add(L5);
p2.add(L6);
p2.add(L7);
p2.add(S1);
p2.add(S2);
p2.add(S3);
add(p2);
p3.setLayout(new BorderLayout());
p3.add("North",p1);
p3.add("South",p2);
add(p3);
p4.setLayout(new BorderLayout(0,2));
p4.add("North",p3);
p4.add("South",B1);
add(p4);
}



public void actionPerformed(ActionEvent e){
word=T1.getText();
size= word.length();
repaint();
}

public void adjustmentValueChanged(AdjustmentEvent e){
if(e.getSource()==S1)
R=S1.getValue();
if(e.getSource()==S2)
G=S2.getValue();
if( e.getSource()==S3)
B=S3.getValue();
// setForeground(new Color(R,G,B));
repaint();
}
public void paint(Graphics g) {
int pos=0;
int aCount = 0,eCount = 0,iCount = 0,oCount = 0,uCount = 0;

while(pos<size){
switch (word.charAt(pos))
{

case 'a': case 'A':
++aCount;g.setColor(new Color(R,G,B)); break;
case 'e': case 'E':
++eCount;g.setColor(new Color(R,G,B)); break;
case 'i': case 'I':
++iCount;g.setColor(new Color(R,G,B)); break;
case 'o': case 'O':
++oCount;g.setColor(new Color(R,G,B)); break;
case 'u': case 'U':
++uCount;g.setColor(new Color(R,G,B)); break;
}
++pos;
}
g.setColor(new Color(0,0,0)) ;
g.drawString(" A = "+aCount, 8,220);
g.drawString(" E = "+eCount, 8, 240 );
g.drawString(" I = "+iCount, 8, 260 );
g.drawString(" O = "+oCount, 8, 280 );
g.drawString(" U = "+uCount, 8, 300 );
g.drawString("Vowels are displayed in RGB color of ("+R+","+G+","+B+").", 10,200);
Font font=new Font("Serif",Font.BOLD,17);
g.setFont(font);
// g.setColor(new Color(R,G,B));
g.drawString(""+word, 8, 180 );

}
}


this is what i did..but not working..i just want only my vowels 2 change color when i change ma scrollbar
Reply With Quote Quick reply to this message  
Join Date: Jan 2006
Posts: 7
Reputation: dammika is an unknown quantity at this point 
Solved Threads: 0
dammika dammika is offline Offline
Newbie Poster

Re: need help...

 
0
  #8
Jan 24th, 2006
hey any one know how to convert a string in to char...
it will be really gr8..if some one can help me asap...
thank u....
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6,143
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 213
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: need help...

 
0
  #9
Jan 24th, 2006
no, I'm not going to help you asap. I MIGHT help you if you ask nicely in a year or so.
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,273
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 378
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

Re: need help...

 
0
  #10
Jan 24th, 2006
Originally Posted by jwenting
no, I'm not going to help you asap. I MIGHT help you if you ask nicely in a year or so.


Try this.

  1. class isYou
  2. {
  3. public static void main(String[] args)
  4. {
  5. String thwee = "iamthwee";
  6. char[] what = thwee.toCharArray();
  7. for(int dex=0; dex<what.length; dex++)
  8. {
  9. System.out.print(what[dex]);
  10. System.out.println("\n");
  11. }
  12. }
  13. }
*Voted best profile in the world*
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the Java Forum
Thread Tools Search this Thread



Tag cloud for Java
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC