分享
 
 
 

简单学生成绩管理系统(Java实现)

王朝java/jsp·作者佚名  2006-01-10
窄屏简体版  字體: |||超大  

/**Copyright (C) Guan Chengwen at Xiamen University

**2005-12-25

**Student ID: 03231004, Philosophy Department

**Email: mydream2007@hotmail.com QQ: 233204600

**Homepage: http://blog.csdn.net/aprin/

**

**File: Main.java

**Package: aprin.stu_sys

*/

package aprin.stu_sys;

import java.lang.*;

import java.io.*;

import aprin.stu_sys.*;

public class Main

{

public static void main(String[] args)

{

while(true)

{

Menu.paint();

int ctrlTag = Console.readInt();

switch(ctrlTag)

{

case 1:

{

Menu.action1();

break;

}

case 2:

{

Menu.action2();

break;

}

case 3:

{

Menu.action3();

break;

}

case 4:

{

Menu.action4();

break;

}

case 5:

{

Menu.action5();

break;

}

case 6:

{

Menu.action6();

break;

}

case 0:

{

System.exit(0);

break;

}

}

}

}

}

class Student

{

private int number;

private String name;

private int english;

private int math;

private int computer;

private int average;

private int total;

public Student()

{

}

public Student(int number, String name, int english, int math, int computer)

{

this.number = number;

this.name = name;

this.english = english;

this.math = math;

this.computer = computer;

total = english + math + computer;

average = total/3;

}

public int getNumber()

{

return number;

}

public String getName()

{

return name;

}

public int getEnglish()

{

return english;

}

public int getMath()

{

return math;

}

public int getComputer()

{

return computer;

}

public int getAverage()

{

return average;

}

public int getTotal()

{

return total;

}

}

class StudentSet

{

private static final int maxLen = 1000;

private static int len = 0;

private static Student[] data = new Student[maxLen];

public static int getMaxLen()

{

return maxLen;

}

public static int getLen()

{

return len;

}

public static Student getData(int index)

{

return data[index];

}

public static int addData(Student newData)

{

if (len < maxLen)

{

data[len] = newData;

len++;

return 0;

} else

{

return -1;

}

}

public static void sortData()

{

for (int i = 0; i < len -1; i++)

{

int minIndex = i;

for (int j = i+1; j < len; j++)

{

if (data[minIndex].getAverage() > data[j].getAverage())

{

minIndex = j;

}

}

if (minIndex != i)

{

Student temp = data[i];

data[i] = data[minIndex];

data[minIndex] = temp;

}

}

}

public static int search(int number)

{

for(int i = 0; i < len; i++)

{

if (data[i].getNumber() == number)

{

return i;

}

}

return -1;

}

public static int delete(int number)

{

for (int i = 0; i < len; i++)

{

if (data[i].getNumber() == number)

{

for (int j = i + 1; j < len; j++)

{

data[j-1] = data[j];

}

len--;

return 0;

}

}

return -1;

}

public static int stat(int min, int max)

{

int sum =0;

for (int i = 0; i < len; i++)

{

if ((data[i].getAverage() >= min) && (data[i].getAverage() <= max))

{

sum++;

}

}

return sum;

}

}

class Console

{

public static int readInt()

{

int result = 0;

try{

String temp =new BufferedReader(new InputStreamReader(System.in)).readLine();

result = Integer.parseInt(temp);

} catch (Exception e)

{

System.out.println("Error: "+e);

}

return result;

}

public static String readSting()

{

String result = null;

try{

result = new BufferedReader(new InputStreamReader(System.in)).readLine();

} catch (Exception e)

{

System.out.println("Error: "+e);

}

return result;

}

}

class Menu

{

public static void paint()

{

clrscr();

for (int i = 0; i < 80; i++)

{

System.out.print('=');

}

System.out.println();

System.out.println(" 学生成绩管理系统 ");

System.out.println();

System.out.println(" 1 输入记录 2 输出所有记录");

System.out.println(" 3 按平均成绩排序并输出 4 查找记录");

System.out.println(" 5 统计各分数段人数 6 删除记录");

System.out.println(" 0 退出");

for (int i = 0; i < 80; i++)

{

System.out.print('=');

}

System.out.println(" Copyright (C) 2005 官成文 厦门大学");

System.out.println();

System.out.print("请输入命令:");

}

public static int action1()

{

while(true)

{

clrscr();

System.out.print("待输入记录的学号(输入“-1”退出):");

int number = Console.readInt();

if (number != -1)

{

System.out.print(" *姓名:");

String name = Console.readSting();

System.out.print(" *英语:");

int english = Console.readInt();

System.out.print(" *数学:");

int math = Console.readInt();

System.out.print(" *计算机:");

int computer = Console.readInt();

Student newData = new Student(number, name, english, math, computer);

if (StudentSet.addData(newData) == -1)

{

System.out.println("数据溢出!");

return -2;

}

} else

{

return -1;

}

}

}

public static void action2()

{

clrscr();

if (StudentSet.getLen() == 0)

{

System.out.println("没有记录!");

} else

{

System.out.println(" 数学|英语|计算机|平均|总计");

for (int i = 0; i < StudentSet.getLen(); i++)

{

System.out.println("学号:"+StudentSet.getData(i).getNumber()+" 姓名:"+StudentSet.getData(i).getName());

System.out.println(" "+StudentSet.getData(i).getMath()+" "+StudentSet.getData(i).getEnglish()+

" "+StudentSet.getData(i).getComputer()+" "+StudentSet.getData(i).getAverage()+" "+StudentSet.getData(i).getTotal());

}

}

}

public static void action3()

{

StudentSet.sortData();

action2();

}

public static void action4()

{

clrscr();

System.out.print("请输入要查找记录的学号:");

int number = Console.readInt();

int i;

if ((i = StudentSet.search(number)) != -1)

{

clrscr();

System.out.println(" 数学|英语|计算机|平均|总计");

System.out.println("学号:"+StudentSet.getData(i).getNumber()+" 姓名:"+StudentSet.getData(i).getName());

System.out.println(" "+StudentSet.getData(i).getMath()+" "+StudentSet.getData(i).getEnglish()+

" "+StudentSet.getData(i).getComputer()+" "+StudentSet.getData(i).getAverage()+" "+StudentSet.getData(i).getTotal());

} else

{

System.out.println("没有找到相应的记录!");

}

}

public static void action5()

{

clrscr();

System.out.println("90-100: "+StudentSet.stat(90, 100)+"人");

System.out.println("80-89: "+StudentSet.stat(80, 89)+"人");

System.out.println("70-79: "+StudentSet.stat(70, 79)+"人");

System.out.println("60-69: "+StudentSet.stat(60, 69)+"人");

System.out.println("0-59: "+StudentSet.stat(0, 59)+"人");

}

public static void action6()

{

while(true)

{

clrscr();

System.out.print("请输入要删除记录的学号(输入“-1”退出):");

int number = Console.readInt();

if (number != -1)

{

if(StudentSet.delete(number) == -1)

{

System.out.println("没有找到相应的记录!");

return;

} else

{

System.out.println("删除记录成功!");

}

} else

{

return;

}

}

}

public static void clrscr()

{ //temp function

System.out.println();

System.out.println();

}

}

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有