/*学号分析。 请参照任务说明在下面的【】处补充代码*/ import java.util.Scanner; public class NumberAnalyse { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String number,grade,school,major,classNo,num;; //学号,年级,学院号,专业号,班级号,班内序号 System.out.println("输入学号:"); number = 【】; //获取字符串number中的每个部分 【】 【】 【】 【】 【】 //可以继续获取该专业的班级号,该学生在班内的序号 System.out.printf("学号:%s,年级:%s,所在学院号:%s,所在专业号:%s,所在专业班级号:%s,班内序号:%s\n",【】,【】,【】,【】,【】,【】); sc.close(); } }
时间: 2024-02-20 19:57:34 浏览: 28
好的,下面是完整的代码,已经补充了缺失的部分:
```java
import java.util.Scanner;
public class NumberAnalyse {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String number,grade,school,major,classNo,num; //学号,年级,学院号,专业号,班级号,班内序号
System.out.println("输入学号:");
number = sc.next();
//获取字符串number中的每个部分
grade = number.substring(0,2);
school = number.substring(2,4);
major = number.substring(4,6);
classNo = number.substring(6,7);
num = number.substring(7);
//获取该专业的班级号,该学生在班内的序号
classNo = String.valueOf(Integer.parseInt(classNo));
num = String.valueOf(Integer.parseInt(num));
System.out.printf("学号:%s,年级:%s,所在学院号:%s,所在专业号:%s,所在专业班级号:%s,班内序号:%s\n", number,grade,school,major,classNo,num);
sc.close();
}
}
```
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)