java学号自增代码 java学号用什么类型定义

编写一个java程序,要求输入自己的学号姓名

import java.io.BufferedReader;

成都创新互联服务项目包括新林网站建设、新林网站制作、新林网页制作以及新林网络营销策划等。多年来,我们专注于互联网行业,利用自身积累的技术优势、行业经验、深度合作伙伴关系等,向广大中小型企业、政府机构等提供互联网行业的解决方案,新林网站推广取得了明显的社会效益与经济效益。目前,我们服务的客户以成都为中心已经辐射到新林省份的部分城市,未来相信会继续扩大服务区域并继续获得客户的支持与信任!

import java.io.IOException;

import java.io.InputStreamReader;

public class Test222 {

public static void main(String[] args) throws IOException {

int i, j;

String a;

BufferedReader str = new BufferedReader(

new InputStreamReader(System.in));

System.out.println("请输入学号:");

a = str.readLine();

System.out.println("学号为:" + a);

str = new BufferedReader(new InputStreamReader(System.in));

System.out.println("请输入姓名:");

a = str.readLine();

System.out.println("姓名为:" + a);

}

}

望采纳~~

如何用JAVA写一个计数器让它能自动按顺序产生学号或员工编号这类的资料呢?

你的这个问题其实挺有意思的,你先想一下你这个表打算怎么设计。

首先你先要设计一个年级班级表,比如年级表就是2015.2016.2015 级。然后班级表。计算机系

01软件工程02应用化学03。不细分了,就是按系就是班了。

那么学生表就是

id      stu_id greed class  name .....其他信息

主键    学号   年级 班级   名字   其他

大概就这个简单设计下。greed和class在其他的表都有这个东西,所以就根据这两个的规则来

生成学生的学号。在录入的时候先查已经入库的这个年纪班级下的所有记录。如果有就有一个

学号的id比如2015 01 110 这个。这样再新增就给下一个学生+1 。如果没有,那么就从

201501001开始往上加。

这种问题其实你可以想一下你们学校的学号是怎么设计的。

如何编写一个随机出学号的Java程序

import java.util.*;

public class RandomStudentId{

private int studentID;

private Random rand = new Random();

//private Set s = new HashSet();

public void RandID(){

studentID = rand.nextInt(1000); //这里写多少,就是从0到多少的随机数字

}

public int getID(){

return studentID;

}

public String toString(){

return "Student ID: " + studentID;

}

public static void main(String[] args){

RandomStudentId rsi = new RandomStudentId();

for(int i=0; i100; ++i){

rsi.RandID();

System.out.println("NO." + rsi.getID());

}

}

}

用java的if语句编写个班级管理程序,用于接收姓名实例化,可以自动分配学号和班级

public static void main(String... args) {

// 姓名列表

String[] names = new String[]{"张1", "张2", "张3", "张4", "张5", "张6", "张7", "张8", "张9", "张10", "张11", "张12", "张13", "张14",

"张15", "张16", "张17", "张18", "张19", "张20", "张21", "张22", "张23"};

MapString, ListJSONObject result = new HashMap();

String classIndex = "class%s";

for (int i = 0; i  names.length; i++) {

String classKey = String.format(classIndex, Integer.parseInt(String.valueOf(i / 10)) + 1);

JSONObject person = new JSONObject();

person.put("id", StringUtils.leftPad(String.valueOf(i + 1), 5, "0"));

person.put("name", names[i]);

person.put("class", classKey);

ListJSONObject classValues = result.get(classKey);

if (null == classValues) {

classValues = new ArrayList();

classValues.add(person);

result.put(classKey, classValues);

} else {

classValues.add(person);

}

}

System.out.println(JSONObject.toJSONString(result));

}


标题名称:java学号自增代码 java学号用什么类型定义
文章出自:http://lszwz.com/article/ddjehop.html

其他资讯

售后响应及时

7×24小时客服热线

数据备份

更安全、更高效、更稳定

价格公道精准

项目经理精准报价不弄虚作假

合作无风险

重合同讲信誉,无效全额退款