Remove the words that begin with two consonants. Need hep with this.
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
Remove the words that begin with two consonants. Need hep with this.
Remove the words that begin with two consonants.
package pi11b_savarankiskas_d;
import java.util.StringTokenizer;
public class Pi11b_savarankiskas_d {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
byte bsak[]=new byte[100];
System.out.println("Įvesti sakinį:");
try{
int bytes=System.in.read(bsak);
}
catch(Exception e){
System.out.println(e);
}
finally{
String strsa=new String(bsak);
fun(strsa);
}
}
public static void fun(String sak) {
System.out.println("Įvestas sakinys:"+sak);
String sep=" ,;:?!.";
String zodis;
final int N=13;
String [] strzodmas=new String[N];
StringTokenizer x=new StringTokenizer(sak,sep);
int kiek = x.countTokens();
//int nT=x.countTokens();
int i=0;
while(x.hasMoreTokens())
{
zodis=x.nextToken();
strzodmas[i++]=zodis;
}
int j;
char[] c=new char[20];
c[0] = 'b';
c[1] = 'c';
c[2] = 'č';
c[3] = 'd';
c[4] = 'f';
c[5] = 'g';
c[6] = 'h';
c[7] = 'j';
c[8] = 'k';
c[9] = 'l';
c[10] = 'm';
c[11] = 'n';
c[12] = 'p';
c[13] = 'r';
c[14] = 's';
c[15] = 'š';
c[16] = 't';
c[17] = 'v';
c[18] = 'z';
c[19] = 'ž';
for (j=0; j<kiek; j++)
{
char pirmas = strzodmas[j].charAt(0);
char antras = strzodmas[j].charAt(1);
if((pirmas != c[0]) && (pirmas != c[1]) && (pirmas != c[2]) && (pirmas != c[3]) && (pirmas != c[4]) && (pirmas != c[5]) && (pirmas != c[6]) && (pirmas != c[7]) && (pirmas != c[8]) && (pirmas != c[9]) && (pirmas != c[10]) && (pirmas != c[11]) && (pirmas != c[12]) && (pirmas != c[13]) && (pirmas != c[14]) && (pirmas != c[15]) && (pirmas != c[16]) && (pirmas != c[17]) && (pirmas != c[18]) && (pirmas != c[19]) )
{
System.out.println(strzodmas[j]);
}
else if ((antras != c[0]) && (antras != c[1]) && (antras != c[2]) && (antras != c[3]) && (antras != c[4]) && (antras != c[5]) && (antras != c[6]) && (antras != c[7]) && (antras != c[8]) && (antras != c[9]) && (antras != c[10]) && (antras != c[11]) && (antras != c[12]) && (antras != c[13]) && (antras != c[14]) && (antras != c[15]) && (antras != c[16]) && (antras != c[17]) && (antras != c[18]) && (antras != c[19]))
{
System.out.println(strzodmas[j]);
}
}
}
}
Please edit your post using code tags
It makes things much easier to read and follow the logical flow of
your program.
Wishes Ada xx
If to Err is human - then programmers are most human of us all.
"The Analytical Engine offers a new, a vast, and a powerful language . . .
for the purposes of mankind."
— Augusta Ada Byron, Lady Lovelace (1851)
Hi Welcome to the forum.
Please do not double post your questions, keep them in the one
domain.
Moderator Request:
Please move or remove this thread.
Wishes Ada xx
If to Err is human - then programmers are most human of us all.
"The Analytical Engine offers a new, a vast, and a powerful language . . .
for the purposes of mankind."
— Augusta Ada Byron, Lady Lovelace (1851)
Threads merged. Thanks, Ada.