当前位置: 代码迷 >> Eclipse >> 新手做JAVA学生成绩管理系统碰到的小疑点
  详细解决方案

新手做JAVA学生成绩管理系统碰到的小疑点

热度:45   发布时间:2016-04-23 13:35:50.0
新手做JAVA学生成绩管理系统碰到的小问题
[code=Java][/code]
packsubject jesse;
import java.io.*;

public class stu
{ public static int bianhao=0,f_bh;
  public static int bh;
  public static String s;
public static class student
{  
public int bianhao;
public String name;
  public String subject;
  public String sex;

};
public static student[] st=new student[100];
  


public static void main(String args[])
{  
for(int i=0;i<=99;i++)
{ st[i]=new student();
st[i].bianhao=-1;
}
System.out.print("*******************\n**欢迎使用学生信息管理系统**\n*******************\n");
first();
  xz(); 
 

}
public static void xz()
{
while(true)
{
System.out.print("请输入:");
try
{ BufferedReader Console=new BufferedReader(new InputStreamReader(System.in));

s=Console.readLine();
bh=Integer.parseInt(s);
break;
}
catch(Exception e)
{
System.out.print("你输入的有误,请输入(1,2,3,4,5,0)其中人一个\n");
}
}

switch(bh)
{
case 0:break;
case 1:add();first();xz();break;
case 2:del();first();xz();break;
case 3:mod();first();xz();break;
case 4:find();first();xz();break;
case 5:showall();first();xz();break;

}

}
  public static void first()
{
   
System.out.print("1---增加\n");
System.out.print("2---删除\n");
System.out.print("3---修改\n");
System.out.print("4---查询\n");
System.out.print("5---显示\n");
System.out.print("0---退出\n");

}
public static void add()

{
while(true)

{
try{
BufferedReader Console=new BufferedReader(new InputStreamReader(System.in));
System.out.println("请输入编号:"+(int)(bianhao+1));
st[bianhao].bianhao=(int)(bianhao+1);
System.out.print("请输入姓名:");
s=Console.readLine();
st[bianhao].name=s;
System.out.print("请输入科目:");
st[bianhao].subject=Integer.parseInt(Console.readLine());
System.out.print("请输入性别:");
s=Console.readLine();
st[bianhao].sex=s;
bianhao++;
  System.out.print("是否继续输入?(y/n)");
while(true)
{
s=Console.readLine();
if(!s.equals("y") && !s.equals("n"))
{
System.out.print("有错,请重新输入");

}
else
{break;
}
}
if(s.equals("n"))
{
break;
}
}
  catch(Exception e)
  {
  System.out.print("错误");

  }
}
}
public static void del()
{ try{
BufferedReader Console=new BufferedReader(new InputStreamReader(System.in));
System.out.print("请输入学生编号");
while(true)
{
f_bh=Integer.parseInt(Console.readLine());
if (f_bh>=1 && f_bh<=100)
{
if(show(f_bh-1))
{
System.out.print("确认删除?(y/n)");
while(true)
{
s=Console.readLine();
if(!s.equals("y") && !s.equals("n"))
{
System.out.print("有错,请重新输入");
}
else
{
break;
}
}
if(s.equals("n"))
{

break; 
}
else if(s.equals("y"))
{
st[f_bh-1].bianhao=-1;
st[f_bh-1].name="";
st[f_bh-1].subject=0;
st[f_bh-1].sex="";
System.out.print("删除成功");
break;
}


}
else

{break;
}

}
else
{
System.out.print("你输入的编号不在1-100内,重输");
}
}

}
catch(Exception e)
{

System.out.print("错误");
  }
}
public static void mod()
  { try{
  相关解决方案