程序7
来源:互联网 发布:画房屋平面图软件 编辑:程序博客网 时间:2024/06/04 19:24
/*题目:输入一行字符,分别统计出其中英文字母、空格、数字和其它字符的个数。*/import java.util.*;public class Example07{public static void main(String args[]){int abcCount=0;//英文字母数量int spaceCount=0;//空格数量int numCount=0;//数字数量int otherCount=0;Scanner scan=new Scanner(System.in);System.out.print("请输入一行字符:");String str=scan.nextLine();//读取键盘输入char[] ch=str.toCharArray();for(int i=0;i<ch.length;i++){if(Character.isLetter(ch[i])){//判断是否是字母abcCount++;}else if(Character.isDigit(ch[i])){//判断是否是数字 numCount++; } else if(Character.isSpaceChar(ch[i])){//判断是否是空格 spaceCount++; } else{//其它字符 otherCount++; }}System.out.println("字母个数:"+abcCount);System.out.println("数字个数:"+numCount);System.out.println("空格个数:"+spaceCount);System.out.println("其他字符个数:"+otherCount);}}
阅读全文
0 0
- 【程序7】
- 程序7
- 程序7
- 实验7 程序优化
- 程序5-7 RandRect
- 7zip程序定制
- 【程序7】数制转换
- 7-1程序改错
- (7)Ping程序
- 7 程序调试进阶
- 阅读程序(7)
- 20157:补足程序7
- Windows 7便签程序
- 程序
- 程序
- 程序
- 程序!~~`````
- 程序
- n阶行列式计算Python和C语言实现
- java学习初探十三之集合
- sscanf函数
- 执行npm install的时候报错:Cannot download "https://github.com/sass/node-sass/releases/download/v3.13.1/win3
- Oracle AQ
- 程序7
- Python的一些基础
- sicp练习2.6
- spring集成 log4j + slf4j
- BoxFilter的Matlab实现方法
- LAMP架构之eclipse
- java动态代理(JDK和cglib)
- 设计模式——工厂模式
- CSS3实现瀑布流效果