import java.util.Scanner;
public class Student{
public static void main(String[] args) {
Scanner scanner =new Scanner(System.in);
String studentID="2023001225";
int sum=0;
for (int i = 0; i <studentID.length() ; i++) {
sum += Character.getNumericValue(studentID.charAt(i));
}
System.out.println("学号的数字之和为:"+sum);
}
}
用JAVA编写一段程序,程序求自己长学号的数字和,例如学号为“2023001225“
最新推荐文章于 2024-11-09 12:43:52 发布