package test;
import java.util.Scanner;
public class test {
public static void main(String[] args) {
while(true){
Scanner input=new Scanner(System.in);
System.out.print("请输入带字母的字符串:");
String str1=input.next();
int counA=0;
int couna=0;
for(int i=0;i<str1.length();i++){
if((byte)str1.charAt(i)>64&&(byte)str1.charAt(i)<91){
counA++;
}else if((byte)str1.charAt(i)>96&&(byte)str1.charAt(i)<123){
couna++;
}
}
if(counA==0&&couna==0){
System.out.println("输入错误,请重新输入带字母的字符串:");
}else if(counA==0){
System.out.println("输入的字符串中含大写字母0个");
}else{
System.out.println("大写字母有"+counA+"个");
}
}
}
}
纯手打,望采纳