高分悬赏! 哪位java的高手进来帮我编程啊,十分感谢!

来源:百度知道 编辑:UC知道 时间:2024/06/05 16:24:48
输入一字符串,删除其中单词中的元音字母,保留的单个元音字母,将两个连续相同的非元音字母去除一个,将结果输出,并计算单词数和平均每个单词删除的字数
就是说如果输进一个元音字母是不变的,比如输进a,出来的还是a,不能把它删掉了,可以帮我修改一下吗??谢谢!

这样就行:
import java.io.*;
public class Demon
{
public static void main(String args[])
{
try
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String str="";
String sen="";//英文句子
String[] word;
int count;
double percent;
while(str.matches("[nN]")==false)
{
System.out.println("Please enter a Sentence");
sen=br.readLine();
count=sen.length();//记录句子的原长
word=sen.split("\\s");//分割句子为单词数组
sen="";
for(String temp : word) //去除元音字母和重复字符
{
temp=temp.replaceAll("[aeiou]","");
temp=temp.replaceAll("(?s)(.)(?=.?\\1)", "");
sen+=temp+" ";
}
percent=(double)(count-sen.length()+1)/(double)word.length;//计算平均每个单词删除的字数
System.