java计算5个字母的单词数量,java编程题从键盘输入一段英文,统计这段文字中单词的个数,并输出其中由四个字母组成的单词以5个一行输...

import java.util.Scanner;

public class SplitWords {

public static void main(String[] args) {

System.out.println(Please input some english words,separate with ',' or SPACE );

Scanner scanner = new Scanner(System.in);

String input = scanner.nextLine();

String[] words = input.replace(',',' ').replace('.',' ').split(\\s+);

System.out.println(Total + words.length + separate word in + input);

System.out.println(Words with 4 characters are as follows:);

int count = 0;

for(String str:words){

if(count == 5){

System.out.println();

count = 0;

}

if(str.length() == 4){

System.out.print(str + \t);

count++;

}

}

}

}

------------------

Please input some english words,separate with ',' or SPACE

Today is Christmas Day,we people in china don't celebrate it.I like china very much.

Total 16 separate word in Today is Christmas Day,we people in china don't celebrate it.I like china very much.

Words with 4 characters are as follows:

like very much

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值