java实现学生成绩档案管理系统

网友投稿 267 2022-10-10


java实现学生成绩档案管理系统

本文实例为大家分享了java实现学生成绩档案管理系统的具体代码,供大家参考,具体内容如下

实验要求

• 学生信息录入,信息包括学号、姓名、专业、四门课成绩、总分、名次;

• 系统可对学生信息浏览、增加、删除和修改;

• 按学生成绩确定名次及信息输出,双向冒泡排序、希尔排序、快速排序、堆 排序。

• 要求可对学生信息查询,根据学号或姓名进行查找;

• 信息修改仅可修改四门课成绩;

• 文件存取学生信息

实验设计

• 新增学生信息(包括学号、姓名、专业、4门课成绩……)

• 浏览学生信息(对学生排序后信息进行浏览)

• 删除学生信息(删除指定学生的信息,可给用户选择检索指定项)

• 查找学生信息(查找符合条件的某条记录)

• 保存学生信息(保存学生成绩档案信息到文本文件)

• 加载学生信息(登录系统后将磁盘文件中保存的学生成绩信息读

取到内存中)

实验分析

初步分析

本实验采用dao模式进行编写,由于暂时没有学习数据库,故新建一个类来模拟保存数据库,此外,本人想法是将数据保存于excel文件中,并从excel文件中读取数据。

算法设计

快速排序

/**

* 快速排序

* 递归

*/

private void quickSort(List stuInfosList, int left, int right) {

if UEHARNPoN(left >= right) {

return ;

}

int l = left;

int r = right;

//基准值,取中间

int key = stuInfosList.get(left).getSum();

boolean flag=true;

//交换容器

StuInfo student;

while (l != r) {

if(flag){

if(key

student = stuInfosList.get(r);

stuInfosList.set(r, stuInfosList.get(l));

stuInfosList.set(l, student);

flag=false;

}else{

r--;

}

}else {

if (key>stuInfosList.get(l).getSum()){

student = stuInfosList.get(r);

stuInfosList.set(r, stuInfosList.get(l));

stuInfosList.set(l, student);

flag=true;

}else {

l++;

}

}

}

quickSort(stuInfosList,left, r - 1);

quickSort(stuInfosList, l + 1, right);

}

双向冒泡排序

/**

* 双向冒泡排序

*/

private void doubleBubbleSort(List stuInfosList) {

//设置一个交换容器

StuInfo student;

//左右指针

int left = 0, right = stuInfosList.size() - 1;

while (left < right) {

for (int i = left + 1; i <= right; i++) {

if (stuInfosList.get(left).getSum() < stuInfosList.get(i).getSum()) {

student = stuInfosList.get(i);

stuInfosList.set(i, stuInfosList.get(left));

stuInfosList.set(left, student);

}

}

left++;

for (int i = right; i >= left; i--) {

if (stuInfosList.get(right).getSum() > stuInfosList.get(i).getSum()) {

http:// student = stuInfosList.get(i);

stuInfosList.set(i, stuInfosList.get(right));

stuInfosList.set(right, student);

}

}

right--;

}

}

堆排序

/**

* 堆排序

*/

private void heapSort(UEHARNPoNList stuInfosList) {

//建堆

buildHeap(stuInfosList);

StuInfo student;

for (int i = stuInfosList.size() - 1; i >= 1; i--) {

//交换

student = stuInfosList.get(i);

stuInfosList.set(i, stuInfosList.get(0));

stuInfosList.set(0, student);

//堆调整

heapfity(stuInfosList, 0, i - 1);

}

}

/**

* 堆调整

*/

private void heapfity(List stuInfosList, int index, int len) {

int lchild = index * 2 + 1;

int rchild = index * 2 + 2;

StuInfo student;

int temp = 0;

if (lchild <= len && rchild <= len) {

temp = stuInfosList.get(lchild).getSum() < stuInfosList.get(rchild).getSum() ? lchild : rchild;

} else if (lchild <= len) {

temp = lchild;

} else if (rchild <= len) {

temp = rchild;

}

//

if (stuInfosList.get(temp).getSum() < stuInfosList.get(index).getSum()) {

student = stuInfosList.get(temp);

stuInfosList.set(temp, stuInfosList.get(index));

stuInfosList.set(index, student);

}

}

/**

* 建立小根堆

*/

private void buildHeap(List stuInfosList) {

for (int i = stuInfosList.size() / 2 - 1; i >= 0; i--) {

heapfity(stuInfosList, i, stuInfosList.size() - 1);

}

}

希尔排序

/**

* 希尔排序

*/

private void shellSort(List stuInfosList) {

int step = stuInfosList.size() / 2;

while (step >= 1) {

for (int start = 0; start < step; start++) {

insertSort(stuInfosList, step, start);

}

step /= 2;

}

}

/**

* 希尔排序循环内使用的插入排序

*/

private void insertSort(List stuInfosList, int step, int start) {

//交换容器

StuInfo student;

for (int i = start + step; i < stuInfosList.size(); i += step) {

for (int j = i; j - step >= 0 && stuInfosList.get(j).getSum() > stuInfosList.get(j - step).getSum(); j -= step) {

student = stuInfosList.get(j);

stuInfosList.set(j, stuInfosList.get(j - step));

stuInfosList.set(j - step, student);

}

}

}

student = stuInfosList.get(r);

stuInfosList.set(r, stuInfosList.get(l));

stuInfosList.set(l, student);

flag=false;

}else{

r--;

}

}else {

if (key>stuInfosList.get(l).getSum()){

student = stuInfosList.get(r);

stuInfosList.set(r, stuInfosList.get(l));

stuInfosList.set(l, student);

flag=true;

}else {

l++;

}

}

}

quickSort(stuInfosList,left, r - 1);

quickSort(stuInfosList, l + 1, right);

}

双向冒泡排序

/**

* 双向冒泡排序

*/

private void doubleBubbleSort(List stuInfosList) {

//设置一个交换容器

StuInfo student;

//左右指针

int left = 0, right = stuInfosList.size() - 1;

while (left < right) {

for (int i = left + 1; i <= right; i++) {

if (stuInfosList.get(left).getSum() < stuInfosList.get(i).getSum()) {

student = stuInfosList.get(i);

stuInfosList.set(i, stuInfosList.get(left));

stuInfosList.set(left, student);

}

}

left++;

for (int i = right; i >= left; i--) {

if (stuInfosList.get(right).getSum() > stuInfosList.get(i).getSum()) {

http:// student = stuInfosList.get(i);

stuInfosList.set(i, stuInfosList.get(right));

stuInfosList.set(right, student);

}

}

right--;

}

}

堆排序

/**

* 堆排序

*/

private void heapSort(UEHARNPoNList stuInfosList) {

//建堆

buildHeap(stuInfosList);

StuInfo student;

for (int i = stuInfosList.size() - 1; i >= 1; i--) {

//交换

student = stuInfosList.get(i);

stuInfosList.set(i, stuInfosList.get(0));

stuInfosList.set(0, student);

//堆调整

heapfity(stuInfosList, 0, i - 1);

}

}

/**

* 堆调整

*/

private void heapfity(List stuInfosList, int index, int len) {

int lchild = index * 2 + 1;

int rchild = index * 2 + 2;

StuInfo student;

int temp = 0;

if (lchild <= len && rchild <= len) {

temp = stuInfosList.get(lchild).getSum() < stuInfosList.get(rchild).getSum() ? lchild : rchild;

} else if (lchild <= len) {

temp = lchild;

} else if (rchild <= len) {

temp = rchild;

}

//

if (stuInfosList.get(temp).getSum() < stuInfosList.get(index).getSum()) {

student = stuInfosList.get(temp);

stuInfosList.set(temp, stuInfosList.get(index));

stuInfosList.set(index, student);

}

}

/**

* 建立小根堆

*/

private void buildHeap(List stuInfosList) {

for (int i = stuInfosList.size() / 2 - 1; i >= 0; i--) {

heapfity(stuInfosList, i, stuInfosList.size() - 1);

}

}

希尔排序

/**

* 希尔排序

*/

private void shellSort(List stuInfosList) {

int step = stuInfosList.size() / 2;

while (step >= 1) {

for (int start = 0; start < step; start++) {

insertSort(stuInfosList, step, start);

}

step /= 2;

}

}

/**

* 希尔排序循环内使用的插入排序

*/

private void insertSort(List stuInfosList, int step, int start) {

//交换容器

StuInfo student;

for (int i = start + step; i < stuInfosList.size(); i += step) {

for (int j = i; j - step >= 0 && stuInfosList.get(j).getSum() > stuInfosList.get(j - step).getSum(); j -= step) {

student = stuInfosList.get(j);

stuInfosList.set(j, stuInfosList.get(j - step));

stuInfosList.set(j - step, student);

}

}

}


版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:How to TS Palo Alto IPSec ××× connectivity issues(how are you是什么意思)
下一篇:华为NAT基本配置实例详解(华为nat服务器配置)
相关文章

 发表评论

暂时没有评论,来抢沙发吧~