import java.util.Scanner;
/**
* 操作界面类
*/
public class JieMian{
StudentList yi=new StudentList();
Scanner input = new Scanner(System.in);
/**
* 学员管理主界面
*/
public void caiDan(){
yi.chuShi();
boolean lin=true;
do{
System.out.println("\n-----------ACCP学员管理系统-------------\n");
System.out.println("\t\t1.教员登录");
System.out.println("\t\t2.班主任登录 ");
System.out.println("\t\t0.退出");
System.out.println("\n----------------------------------------");
System.out.print("请选择:");
if(input.hasNextInt()==true){
int choice = input.nextInt();
switch(choice){
case 1:
caiDan1();
break;
case 2:
caiDan2();
break;
case 0:
System.out.println("程序退出,谢谢使用!");
return;
default:
System.out.print("输入有误!请重新输入:");
}
}else{
System.out.print("输入不合法!");
lin=false;
}
}while(lin);
}
/**
* 教员管理界面
*/
public void caiDan1(){
do{
System.out.println("\n----------欢迎进行教员管理模块--------------\n");
System.out.println("\t\t1.登记分数");
System.out.println("\t\t2.扣作业表现分");
System.out.println("\t\t3.显示学员信息");
System.out.println("\t\t4.显示不及格的学员信息");
System.out.println("\t\t0.返回上级菜单");
System.out.println("\n-------------------------------------------");
System.out.print("请选择以上功能:");
int choice = input.nextInt();
switch(choice){
case 1:
System.out.print("请选择登记的项目 1.java 2.html 3.sql :");
int lin=input.nextInt();
if(lin==1){
Student xin=new Student();
System.out.print("请输入登记的姓名:");
xin.name=input.next();
yi.java(xin);
}else if(lin==2){
Student xin=new Student();
System.out.print("请输入登记的姓名:");
xin.name=input.next();
yi.html(xin);
}else if(lin==3){
Student xin=new Student();
System.out.print("请输入登记的姓名:");
xin.name=input.next();
yi.sql(xin);
}else{
System.out.println("输入有误!");
}
return;
case 2:
System.out.print("请输入查找的姓名:");
String name=input.next();
yi.zuoY(name);
break;
case 3:
yi.showAllStudent();
break;
case 4:
yi.showUnPassStudent();
break;
case 0:
return;
default:
System.out.print("输入有误!请重新输入:");
}
}while(true);
}
/**
* 班主任管理界面
*/
public void caiDan2(){
do{
System.out.println("\n----------欢迎进行班主任管理模块--------------\n");
System.out.println("\t\t1.考勤扣分");
System.out.println("\t\t2.显示学员信息");
System.out.println("\t\t3.按成绩高低显示学员信息");
System.out.println("\t\t4.按姓名查找学员");
System.out.println("\t\t5.添加学员");
System.out.println("\t\t0.返回上级菜单");
System.out.println("\n---------------------------------------------");
System.out.print("请选择以上功能:");
if(input.hasNextInt()==true){
int choice = input.nextInt();
switch(choice){
case 1:
System.out.print("请输入查找的姓名:");
String name=input.next();
yi.kaoQ(name);
break;
case 2:
yi.showAllStudent();
break;
case 3:
yi.chengJ();
break;
case 4:
System.out.print("请输入查找的姓名:");
String name1=input.next();
yi.seekStudent(name1);
break;
case 5:
do{
Student xin=new Student();
System.out.print("请输入添加的姓名:");
xin.name=input.next();
if(yi.addStudent(xin)==true){
System.out.println("录入成功!");
}else if(yi.addStudent(xin)==false){
System.out.println("姓名重复!");
}
System.out.println("y继续/其他退出\n是否继续?:");
String lin=input.next();
if(!"y".equals(lin)){
break;
}
}while(true);
break;
case 0:
return;
default:
System.out.print("输入有误!请重新输入:");
}
}else{
System.out.print("输入不合法!程序结束!");
}
}while(true);
}
}
-----------------------------------------------------------------------------------------------------------------------------------
import java.util.Scanner;
/**
* 综合管理类
*/
public class StudentList {
Student[] students=new Student[20];
public void chuShi(){
students[0]= new Student();
students[0].name="小龙女";
students[0].zuoWei=1;
students[0].java=87;
students[0].html=65;
students[0].sql=97;
students[1]= new Student();
students[1].name="嫦娥";
students[1].zuoWei=2;
students[1].java=77;
students[1].html=49;
students[1].sql=83;
students[2]= new Student();
students[2].name="西施";
students[2].zuoWei=3;
students[2].java=31;
students[2].html=93;
students[2].sql=77;
students[3]= new Student();
students[3].name="杨贵妃";
students[3].zuoWei=4;
students[3].java=19;
students[3].html=88;
students[3].sql=59;
students[4]= new Student();
students[4].name="小蛮腰";
students[4].zuoWei=5;
students[4].java=97;
students[4].html=100;
students[4].sql=82;
students[5]= new Student();
students[5].name="貂蝉";
students[5].zuoWei=6;
students[5].java=34;
students[5].html=84;
students[5].sql=76;
}
//显示所有学员信息
public void showAllStudent(){
System.out.println("座位\t"+"姓名\t"+"java成绩\t\t"+"html成绩\t\t"+"sql成绩\t"+"出勤\t"+"作业表现");
for(int i=0;i<students.length;i++){
if(students[i]!=null){
System.out.print(students[i]+"\n");
}
}
}
//添加学员信息,要求不能同名,要有空位才能添加,添加成功返回true
public boolean addStudent(Student a){
boolean jia=false;
for(int lin=0;lin<students.length;lin++){
if(students[lin]!=null){
if(students[lin].name.equals(a.name)){
jia=false;
return jia;
}
}
}
for(int j=0;j<students.length;j++){
if(students[j]==null){
students[j]=new Student();
students[j].zuoWei=j+1;
students[j]=a;
jia=true;
return jia;
}
}
System.out.println("班级学员已满!");
return jia;
}
//根据姓名查找学员姓名,找到返回该学员,没找到返回null
public Student seekStudent(String a){
for(int i=0;i<students.length;i++){
if(students[i]!=null){
if(students[i].name.equals(a)){
System.out.println("座位\t"+"姓名\t"+"java成绩\t\t"+"html成绩\t\t"+"sql成绩\t"+"出勤\t"+"作业表现");
System.out.println(students[i]+"\n");
return students[i];
}
}
}
System.out.println("没有找到该同学!");
return null;
}
//登记java分数
public Student java(Student a){
Scanner input=new Scanner(System.in);
for(int i=0;i<students.length;i++){
if(students[i]!=null){
if(students[i].name.equals(a.name)){
System.out.print("请输入"+a.name+"的java成绩:");
students[i].java=input.nextInt();
System.out.println("登记成功!");
return students[i];
}
}
}
System.out.println("没有找到该同学!");
return null;
}
//登记html分数
public Student html(Student a){
Scanner input=new Scanner(System.in);
for(int i=0;i<students.length;i++){
if(students[i]!=null){
if(students[i].name.equals(a.name)){
System.out.print("请输入"+a.name+"的html成绩:");
students[i].html=input.nextInt();
System.out.println("登记成功!");
return students[i];
}
}
}
System.out.println("没有找到该同学!");
return null;
}
//登记sql分数
public Student sql(Student a){
Scanner input=new Scanner(System.in);
for(int i=0;i<students.length;i++){
if(students[i]!=null){
if(students[i].name.equals(a.name)){
System.out.print("请输入"+a.name+"的sql成绩:");
students[i].sql=input.nextInt();
System.out.println("登记成功!");
return students[i];
}
}
}
System.out.println("没有找到该同学!");
return null;
}
//将不及格的学员找出,自成一个全新的数组返回
public void showUnPassStudent(){
Student[] xin=new Student[20];
int j=0;
for(int i=0;i<students.length;i++){
if(students[i]!=null){
if(students[i].java<60||students[i].html<60||students[i].sql<60){
xin[j]=students[i];
j++;
}
}
}
System.out.println("座位\t"+"姓名\t"+"java成绩\t\t"+"html成绩\t\t"+"sql成绩\t"+"出勤\t"+"作业表现");
for(int a=0;a<xin.length;a++){
if(xin[a]!=null){
System.out.println(xin[a]+"\n");
}
}
}
//按成绩排序,返回一个全新的已排好序的数组,不影响原数组
public Student[] sortByScore(){
Student[] pai=new Student[20];
for(int a=0;a<students.length;a++){
pai[a]=students[a];
}
for(int i=0;i<pai.length-1;i++){ //外层循环决定趟数,数组长度-1
for(int j=pai.length-1;j>i;j--){ //每次得到一个最小或最大的值,放在最上的做位置
if(pai[j]!=null){
if(pai[j].java>pai[j-1].java){ //内层循环从最后元素开始,前后两两比较,进行交换
Student lin = pai[j];
pai[j] = pai[j-1];
pai[j-1] = lin;
}
}
}
}
return pai;
}
/**
* 成绩按高低输出
*/
public void chengJ(){
Student[] xin=new Student[20];
xin=sortByScore();
System.out.println("座位\t"+"姓名\t"+"java成绩\t\t"+"html成绩\t\t"+"sql成绩\t"+"出勤\t"+"作业表现");
for(int i=0;i<students.length;i++){
if(xin[i]!=null){
System.out.println(xin[i]+"\n");
}
}
}
/**
* 扣作业表现分
*/
public void zuoY(String a){
Scanner input=new Scanner(System.in);
for(int i=0;i<students.length;i++){
if(students[i]!=null){
if(students[i].name.equals(a)){
System.out.print("请输入"+a+"要扣的作业表现分:");
int lin=input.nextInt();
students[i].zuoYe=students[i].zuoYe-lin;
System.out.println("修改成功!");
return;
}
}
}
System.out.println("没有找到该同学!");
}
/**
* 扣考勤分
*/
public void kaoQ(String a){
Scanner input=new Scanner(System.in);
for(int i=0;i<students.length;i++){
if(students[i]!=null){
if(students[i].name.equals(a)){
System.out.print("请输入"+a+"要扣的考勤分:");
int lin=input.nextInt();
students[i].chuQin=students[i].chuQin-lin;
System.out.println("修改成功!");
return;
}
}
}
System.out.println("没有找到该同学!");
}
}
-----------------------------------------------------------------------------------------------
/**
* 学生信息类
*/
public class Student{
int zuoWei,chuQin=100,zuoYe=100;
String name;
double java=0,html=0,sql=0;
public String toString(){
return zuoWei+"\t"+name+"\t"+java+"\t\t"+html+"\t\t"+sql+"\t"+chuQin+"\t"+zuoYe;
}
}
-----------------------------------------------------------------------------------
public class XueY {
public static void main(String[] args){
JieMian yi=new JieMian();
yi.caiDan();
}
}